Problem with Imhist method

13 次查看(过去 30 天)
Jason
Jason 2014-10-23
评论: Jason 2014-10-23
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 个评论
Jason
Jason 2014-10-23
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

请先登录,再进行评论。

回答(3 个)

Image Analyst
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(:)));

Michael Haderlein
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
  1 个评论
Jason
Jason 2014-10-23
OK, Im playing with the following, but its not quite there:
%Automate x-axis labels---------------------------------------
[maxval1,idx]=double(max(ROI(:)))
XTck=get(handles.axes6,'XTick');
t_lim = 1e3*ceil(maxval/1000) % get axis limit: 5000
t_ax = 0:t_lim;
n_int = 20; % define # of intervals
t_int = t_lim/n_int;
tt = t_ax(rem(t_ax,t_int)==0); % find tick locations
ttlab = num2cell(tt) % and generate tick labels
%---------------------------------------------------------------
[counts,x] = imhist(ROI,n_int);
set(handles.axes6,'XTick', tt,'XTickLabel',ttlab);
xlim([0 maxval])

请先登录,再进行评论。


Adam
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 个评论
Jason
Jason 2014-10-23
But then, the histrogram doesn't tell me the frequency of the "actual" intesnity values?
Adam
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by