how make x and y -axis labels(titles) for histogram of an image?
30 次查看(过去 30 天)
显示 更早的评论
i execute the following matlab code to display histogram of gray scale image with x-axis and y-axis names but i didnot get names in x-axis and y-axis labels.
k=imhist(image)
xlabel('grayscale range')
ylabel('intensity values range');
0 个评论
采纳的回答
Image Analyst
2015-5-2
Your code should have worked. Try my boilerplate code snippet:
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
bar(grayLevels, pixelCount); % Plot it as a bar chart.
grid on;
title('Histogram of original image', 'FontSize', fontSize);
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('Pixel Count', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
更多回答(1 个)
Ahmet Cecen
2015-5-2
编辑:Ahmet Cecen
2015-5-2
This sometimes happens to me too. The problem is xlabel sometimes get stuck BEHIND the imhist colorbar at the bottom. To fix it you can use this instead (may need to play around with the values for your liking):
xlabel('grayscale range')
xl = get(gca,'XLabel');
set(xl,'Position',get(xl,'Position') - [0 60000 0])
And Image Analyst's solution would also work because it gets rid of the default bar at the bottom. Take your pick.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!