Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How it is possible that Gimp while exporting histogram counts more pixels than there
#3
(06-12-2020, 03:40 PM)Ofnuts Wrote: Yes, likely a bug, nice finding.

Didn't see you code, but if you access each pixel in turn using get_pixel(), you code will not scale to real-life images. In Python your can use "pixel regions", which is a nbig array-like structure that you can access in Python (it even supports slices).

from PIL import Image
import numpy as np

img = Image.open('start.bmp')

arr=np.array(img)
print (arr)

#im still learning arrays so i changed it to list that im more familiar with

b=arr.tolist()

print ()

flat_list=[]

for sublist in b:
    for item in sublist:
        flat_list.append(item)




white_dots=0
black_dots=0

for i in flat_list:
    if i == 255:
        white_dots+=1
    if i == 0:
        black_dots+=1

print ('number 255: ', white_dots)
print ('number 0: ', black_dots)


thats my code Smile
thank you very much Big Grin
Reply


Messages In This Thread
RE: How it is possible that Gimp while exporting histogram counts more pixels than there - by niitard - 06-12-2020, 03:47 PM

Forum Jump: