image processing - Python AttributeError: 'list' object has no attribute 'convert' -
i got code answer question paul here trying learn code, got following error when trying run it. had google around , found no solution it. know how should write around it? sorry still new programming
restart: c:/users/310293649/appdata/local/programs/python/python36/equalize.py traceback (most recent call last): file "c:/users/310293649/appdata/local/programs/python/python36/equalize.py", line 24, in <module> lut = equalize(im.histogram()) file "c:/users/310293649/appdata/local/programs/python/python36/equalize.py", line 6, in equalize h = im.convert("l").histogram() attributeerror: 'list' object has no attribute 'convert' here code.
import operator pil import image functools import reduce def equalize(im): h = im.convert("l").histogram() lut = [] b in range(0, len(h), 256): # step size step = reduce(operator.add, h[b:b+256]) / 255 # create equalization lookup table n = 0 in range(256): lut.append(n / step) n = n + h[i+b] # map image through lookup table return im.point(lut*3) if __name__ == "__main__": im = image.open(r'r:\temp\alignedphoto_in_png\aligned_img_1789.png') # calculate lookup table lut = equalize(im.histogram()) # map image through lookup table im = im.point(lut) im.show()
Comments
Post a Comment