Pixel Differnce Histogram Plotting.

조회 수: 1 (최근 30일)
Mostfa Abd El-Aziz
Mostfa Abd El-Aziz 2022년 11월 23일
댓글: Image Analyst 2022년 11월 28일
How to plot histogram for (PDH) analysis like in the attached image

답변 (1개)

Image Analyst
Image Analyst 2022년 11월 24일
You can use histogram or, if you already have the counts (like from histcounts) then use bar.
The title function was also used to put a caption above those plots.
  댓글 수: 2
Mostfa Abd El-Aziz
Mostfa Abd El-Aziz 2022년 11월 28일
Can you provide me an example of this sugessted code please??
Image Analyst
Image Analyst 2022년 11월 28일
There are examples in the documentation for the functions. You'll see things like this
yourGrayScaleImage = imread('lena_grayscale.jpg');
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(yourGrayScaleImage)
rows = 512
columns = 512
numberOfColorChannels = 1
%--------------------------------------------------------------------------------------------------------
% Convert to grayscale if it's not already
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
fprintf('It is not really gray scale like we expected - it is color\n');
% Extract the blue channel.
yourGrayScaleImage = yourGrayScaleImage(:, :, 3);
% Update the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(yourGrayScaleImage)
end
% Display image.
subplot(2, 1, 1);
imshow(yourGrayScaleImage);
title('Cover')
% Take histogram.
[counts, edges] = histcounts(yourGrayScaleImage, 256);
% Plot Histogram
subplot(2, 1, 2);
bar(edges(1:end-1), counts, 1);
grid on;
title('PDH of Cover')
xlabel('Gray Level')
ylabel('Count')

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

카테고리

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