Hi all, I am following Jan Erik Solem's book "Programming Computer Vision with Python" and I'm just on the first chapter. The book asked us to create a file imtools.py and put down helpful functions there, which we can just call later.
There is a function created for histogram equalization of images (called * histeq*), and saved in imtools.py. When I use this function and type this in IDLE: >>> from PIL import Image >>> from numpy import * >>> im = array(Image.open('Tulips.jpg').convert('L')) >>> im2,cdf = imtools.histeq(im) I get this: Traceback (most recent call last): File "<pyshell#59>", line 1, in <module> im2,cdf = imtools.histeq(im) File "C:\Python27\imtools.py", line 18, in histeq imhist,bins = histogram(im.flatten(),nbr_bins,normed=True) NameError: global name 'histogram' is not defined And the relevant portion in imtools.py is: def histeq(im,nbr_bins=256): """ Histogram equalization of a grayscale image. """ #get image histogram imhist,bins = histogram(im.flatten(),nbr_bins,normed=True) cdf = imhist.cumsum() #Cumulative distribution function cdf = 255* cdf/cdf[-1] #Normalize #Use linear interpolation of cdf to find new pixel values im2 = interp(im.flatten(), bins[:-1],cdf) return im2.reshape(im.shape), cdf ------------------------------------ Can anybody point out where I'm going wrong? I have Python 2.7, NumPY, SciPY etc. Thanks very much Python Newbie!
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor