Numpy and Image error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Solimyr Solimyr
    New Member
    • Jul 2011
    • 1

    Numpy and Image error

    Hi,
    I'm trying to equalize an histogram of a raster image. I'm trying to following the method found in this site:



    So I did the following step:

    Code:
    from PIL import Image
    from numpy import *
    
    im = array(Image.open('AquaTermi_lowcontrast.jpg').convert('L'))
    imhist,bins = histogram(im.flatten(),nbr_bins,normed=True)
    cdf = imhist.cumsum() 
    cdf = 255 * cdf / cdf[-1]
    im2 = interp(im.flatten(),bins[:-1],cdf)
    im2.reshape(im.shape)
    im2.save(filename)
    But I get the following error:

    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    AttributeError: 'numpy.ndarray' object has no attribute 'save'

    Do you know where I wrong?How can I fix it?
    thx
    Last edited by bvdet; Jul 13 '11, 11:35 PM. Reason: Add code tags
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    As the error message indicates, the array object im2 has no save method. If you are trying to create another image, you are going about it the wrong way.

    Comment

    Working...