Problem with Imhist method
Ältere Kommentare anzeigen
I have an image Zoom:
Zoom =
326 313 269 237 255 329
332 271 304 256 332 302
330 320 265 215 274 316
233 219 218 224 221 224
260 224 203 226 193 210
272 231 219 227 205 227
when I perform
figure
imhist(Zoom)
the histogram is defaulting in the x-axis to x10^4

So the histogram is just a spike.
why does it not autorange the x-axis, and how too?
thanks Jason
1 Kommentar
Jason
am 23 Okt. 2014
Akzeptierte Antwort
Weitere Antworten (3)
Image Analyst
am 23 Okt. 2014
Bearbeitet: Image Analyst
am 23 Okt. 2014
It's using the max of the data type, which is uint16. You can set the x axis to the max of the image varaible after you call imhist() like this:
xlim([0, max(Zoom(:)));
Michael Haderlein
am 23 Okt. 2014
The x scale depends on the data type of the image. I guess in your case, Zoom is of uint16? Then, the limits of the data are [0 65535] and that's the limits of the axes.
Now, the question is, how do to better in your case. Converting to the next smaller data type (uint8) won't help a lot as you have numbers too big for uint8 (must be max 255). Depending on your specific problem, I'd
- either normalize to max=1:
imhist(Zoom/max(Zoom(:)))
- or use the "normal" hist function:
hist(Zoom(:),1:max(Zoom(:)))
Best regards,
Michael
Adam
am 23 Okt. 2014
0 Stimmen
I'm not familiar with imhist, but from a quick look it appears to always use the data type limits for its histogram range so I guess you would need to scale your data up to make better use of the available data range for a histogram using imhist.
Kategorien
Mehr zu Image Filtering finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


