how make x and y -axis labels(titles) for histogram of an image?

조회 수: 32 (최근 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');

채택된 답변

Image Analyst
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
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.

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by