Reputation: 79
%boat_image&histogram
subplot(1,2,1)
imshow(I01);
subplot(1,2,2)
imhist(I01);
saveas( gcf, 'boat_image&histogram', 'jpg' );
I want to cover all y values. How can I change the axis values in terms of the covering maximum value?
after adding following commands, I recieved a different histogram below.
%boat_image&histogram
subplot(1,2,1)
imshow(I02);
subplot(1,2,2)
[cts,x] = imhist(I02);
stem(cts,x);
ylim([0,max(x)]);
saveas( gcf, 'boat_image&histogram_', 'jpg' );
after switch:
%boat_image&histogram
subplot(1,2,1)
imshow(I02);
subplot(1,2,2)
[x,cts] = imhist(I02);
stem(x,cts);
ylim([0,max(x)]);
saveas( gcf, 'boat_image&histogram_', 'jpg' );
after correct switch :)
%boat_image&histogram
subplot(1,2,1)
imshow(I02);
subplot(1,2,2)
[cts,x] = imhist(I02);
stem(x,cts);
ylim([0,max(cts)]);
saveas( gcf, 'boat_image&histogram__', 'jpg' );
There is a big visual gap both first histogram and the last one.
Upvotes: 1
Views: 1514
Reputation: 11628
You could probably use
ylim([0,max_val])
where max_val
is the greatest y-value you want to have displayed.
You could even do that directly using
h = hist(your_data);
ylim([0,max(h)]);
Alternatively when using imhist
you can use the stem
command:
[cts,x] = imhist(img);
stem(x,cts);
ylim([0,max(cts)]);
Upvotes: 2