Just to add, I often use 12 bit images. Occasionally I will use the sum of 3, 12 bit images, so I need the capability to handle both. I would like to limit the number of bins to say 100, but have the x-axis represent the actual intensity, with the max of the x-axis being soemthing related to the max value of intensity in data set
Problem with Imhist method
13 次查看(过去 30 天)
显示 更早的评论
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
回答(3 个)
Image Analyst
2014-10-23
编辑:Image Analyst
2014-10-23
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(:)));
0 个评论
Michael Haderlein
2014-10-23
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
2014-10-23
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.
2 个评论
Adam
2014-10-23
It's just a linear mapping if you are scaling upwards which you would be doing for filling a data type range.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!