How to give Gray color histogram gray shade instead of blue
이전 댓글 표시
Hi, I want the gray shade histogram for grayscale image. here is my code. Can any one help me
% for red color
figure;
imhist(Image_Data(:,:,2));
myHist = findobj(gca, 'Type', 'Stem');
myHist.Color = [0 1 0]
saveas(gcf,'Hist_Org_B.jpg');
%for green color
figure;
imhist(Image_Data(:,:,3));
myHist = findobj(gca, 'Type', 'Stem');
myHist.Color = [0 0 1]
saveas(gcf,'Hist_Org_G.jpg');
채택된 답변
추가 답변 (2개)
Gautam
2024년 8월 29일
Hello Sadika,
I assume that you want to change the colour of the histogram to grey just like the way you have changed to green and blue.
To do this you can use the RGB triplet value of [0.3711 0.3711 0.3711] which is for a shade of grey
figure;
imhist(Image_Data(:,:,3));
myHist = findobj(gca, 'Type', 'Stem');
myHist.Color = [0.3711 0.3711 0.3711];
This gives the plot

% Create sample data.
data = rand(1, 1000);
% Define custom color.
grayColor = [0.4, 0.4, 0.4];
% Plot histogram with 10 gray bins.
histogram(data, 'NumBins', 10, 'FaceColor', grayColor)
댓글 수: 1
When using histogram(), bear in mind that the default facealpha is 0.6. If left against the default axes background, the rendered color will not be what was specified.
rgbpict = imread('peppers.png');
redpict = rgbpict(:,:,1);
histogram(redpict(:),'numbins', 256,'facecolor',[1 0 0],'edgecolor','none')
figure
histogram(redpict(:),'numbins', 256,'facecolor',[1 0 0],'edgecolor','none','facealpha',1)
카테고리
도움말 센터 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!












