Sep-24-2023, 02:28 PM
Dear DPaul, dear deanhystad,
thank you very much for your very good answers!
I wanted to get the number of non-white pixels.
With the help of the outstandingly good answers, I was able to determine this number.
I would like to apologize if I am not very experienced (numpy is still completely new to me).
Thank you again for having this great forum with these very capable members!!
Best regards, flash77
thank you very much for your very good answers!
I wanted to get the number of non-white pixels.
With the help of the outstandingly good answers, I was able to determine this number.
I would like to apologize if I am not very experienced (numpy is still completely new to me).
Thank you again for having this great forum with these very capable members!!
Best regards, flash77
pixels = np.array(Image.open("p2.bmp")) rows, columns, rgba = pixels.shape # to have an array of pixels, not an image: pixels = np.reshape(pixels, (-1, rgba)) count_of_non_white_pixels = 0 for pixel in pixels: r, g, b = pixel if r < 255 or g < 255 or b < 255: count_of_non_white_pixels += 1 print(count_of_non_white_pixels)