How to draw a graph of an image with frequency in y axis and pixel value in x axis in matlab?

조회 수: 2 (최근 30일)
How to draw a graph of an image with frequency in y axis and pixel value in x axis in matlab?
  댓글 수: 3

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

채택된 답변

Image Analyst
Image Analyst 2015년 7월 26일
% Extract the individual red, green, and blue color channels.
redChannel = secret(:, :, 1);
greenChannel = secret(:, :, 2);
blueChannel = secret(:, :, 3);
[pixelCountsR, grayLevelsR] = imhist(redChannel);
[pixelCountsG, grayLevelsG] = imhist(greenChannel);
[pixelCountsB, grayLevelsB] = imhist(blueChannel);
plot(grayLevelsR, pixelCountsR, 'r-', 'LineWidth', 2);
hold on;
plot(grayLevelsG, pixelCountsG, 'r-', 'LineWidth', 2);
plot(grayLevelsB, pixelCountsB, 'r-', 'LineWidth', 2);
grid on;
fontSize = 20;
ylabel('Frequency', 'FontSize', fontSize);
xlabel('Pixel Value', 'FontSize', fontSize);
Then just do the same for share. Then you can use text() and annotation() to add text labels and arrows wherever you want them. Or you can use legend().
  댓글 수: 3
Anushka
Anushka 2015년 8월 21일
편집: Image Analyst 2015년 8월 21일
Hi,Image Analyst
Can you please tell me a way to divide the y axis as shown in the figure ie,0.000,0.002 and so on.
Image Analyst
Image Analyst 2015년 8월 21일
Anushka:
Try this:
x = 0:255;
y = 0.0018 * rand(1, length(x));
plot(x, y, 'b-');
ax = gca;
ax.XTick = 0:50:250;
yTicks = 0:.0002:.0018;
ax.YTick = yTicks;
for k = 1 : length(yTicks)
YTickLabels{k} = sprintf('%.4f', yTicks(k));
end
ax.YTickLabels = YTickLabels;

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

추가 답변 (1개)

Guillaume
Guillaume 2015년 7월 26일

카테고리

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