How to plot a histogram from 0-255
17 views (last 30 days)
I use img1=imread function to load my image into matlab. The image is 512by512 and the intensity range is 0-255. However the histogram of my image ( which I use imhist(img1) to plot it) has values only at 0 and 1. How is that? I mean when I take a look at the array of my picture, I see numbers varying from 0-255. Is it because I am using imhist? Any idea would be appreciated. and sorry if the question might be very basic for some of you.
More Answers (2)
Guillaume on 6 Sep 2016
Most image processing functions expect double images to be in the range 0-1. If the range is 0-255, matlab expects it to be a uint8 image.
a = im2double(imread('yourimage'));
should solve your problem. Or keep the image as uint8.