How to plot the equalized histogram of an image with Python? -
so code. variable img original image. variable eq equalized image.
from matplotlib.pyplot import imread, imshow, show, subplot, title, get_cmap, hist skimage.exposure import equalize_hist img = imread('images/city.tif') eq = equalize_hist(img) subplot(221); imshow(img, cmap=get_cmap('gray')); title('original') subplot(222); hist(img.flatten(), 256, range=(0,256)); title('histogram of origianl') subplot(223); imshow(eq, cmap=get_cmap('gray')); title('histogram equalized') subplot(224); hist(eq.flatten(), 256, range=(0,256)); show() now when run, code, histogram of original fine. histogram of equalized incorrect. of output

what doing wrong ?!?!
edit: builtin matlab commands the answer works fine particular image

it looks it's converting image uint8 format (integer values between 0 , 255 inclusive) float32 or float64 format (floating point values between 0 , 1 inclusive). try eq = np.asarray(equalize_hist(img) * 255, dtype='uint8').
Comments
Post a Comment