채택된 답변

Image Analyst
Image Analyst 2014년 1월 22일

0 개 추천

If you want each bar in a different color, then try the attached demo (below in blue text).

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2014년 1월 22일

1 개 추천

Yes.
help hist
There you'll see that hist with no output parameters plot the histogram with BAR, and that you can get the count and bin position out of hist: [N,X] = hist(...
help bar
There you'll find more information about how to control and set the parameters of a bar plot.
So after reading that, and messing about with get(Bh) you'll end up with this:
[N,X] = hist(...
Bh = bar(X,N,'facecolor',[0.3 0.7 0.2]);
HTH

댓글 수: 3

evangeline
evangeline 2014년 1월 22일
thanks, could u explain more about the N and X? I have read an image, a=imread(); I displayed it in an axes, and displayed the histogram in a different axes, I want to change that hist's color
That's why I prefer explicit, descriptive variable names. N is the pixel counts, and X is the gray level. You might write this as
axes(handles.axesImage); % Use the image axes to show the image.
imshow(grayImage);
axes(handles.axesPlot); % Use the plot axes for the plot.
[pixelCounts, grayLevels] = imhist(grayImage, 256);
bar(grayLevels, pixelCounts, 'FaceColor', [0.3 0.7 0.2]);
This will give 256 bars with each bar the color [0.3 0.7 0.2] which is greenish.
evangeline
evangeline 2014년 1월 22일
thanks, so helpful

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

태그

질문:

2014년 1월 22일

댓글:

2014년 1월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by