The solution to the error of image histogram equalization by Python

knock the code according to the computer vision programming book, this paragraph has been difficult to pass, looking for a solution

related codes

< H1 > here is a program < / H1 >
from PIL import Image
from numpy import *
import imtools

im==array(Image.open("C:/Users/Administrator/Desktop/blow.png").convert("L"))
im2,cdf=imtolld.hidteq(im)

< H1 > here is another program, saved as imtools.py < / H1 >
def histeq(im,nbr_bins=256):
    """"""

    -sharp
    imhist,bins=histogram(im.flatten(),nbr_bins.normed=True)
    
    cdf=imhist.cumsum()-sharp
    cdf=255*cdf/cdf[-1]-sharp
    
    -sharp
    im2=interp(im.flatten(),bins[:-1],cdf)
    return im2.reshape(im.shape),cdf
    



run error message, display:

Traceback (most recent call last):
  File "C:/Users/Administrator/Desktop/ppp.py", line 4, in <module>
    import imtools
  File "C:/Users/Administrator/Desktop\imtools.py", line 20
    imhist,bins=histogram(im.flatten(),nbr_bins.normed=True)
SyntaxError: keyword can"t be an expression

Aug.04,2021

nbr_bins.normed=True this is wrong. The keyword can't be an expression keyword cannot be an expression, and the keyword for calling a function can be normed=True but not the expression a.b=True

.
Menu