1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How can I manually compare two numpy arrays element by element?

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 20:32.

  1. Stack

    Stack Membro Participativo

    I'm trying to implement (in python) a soft comparison between two 2-dimensional images, each with an r,g,b value. They're guaranteed to be the same size. I just want to subtract one from the other and check if any of the elements of that subtraction are above a given tolerance. I think I'm doing this right. Is this the correct way to index and compare two numpy arrays?

    for y in range(0, self.image1.shape[1]):
    for x in range(0, self.image2.shape[0]):
    if max(self.image1[x,y] - self.image2[x,y]) > tolerance:


    I'm trying to compare the results of a subtraction to a tolerance value, using the max() method on the result to pull out the largest difference. The data that I'm working with has three elements to each pixel, r, g, and b. I think this is the right way to do this?

    Continue reading...

Compartilhe esta Página