I am doing this
Write a MATLAB function which computes the 2D joint histogram, GXY ,
of a pair of images, X and Y, of equal size. Test it on the red and green
components of the Queen Butterfly image.
Display the joint histogram, GXY , as a grey level image.
here is my attempt:
function h=histogramtest
A=imread('queen_butterfly_fish.ppm');
h=zeros(size(A,1),size(A,2));
red=A(:,:,1);
green=A(:,:,2);
row=double(red(:)+1);
col=double(green(:)+1);
%h = zeros(256,256);
for i=1:256
for j=1:256
for k = 1:size(row)
% count number of occurences where i == row(k) and j == col(k)
end
% set h(i,j) = count value you get from previous loop
end
end
imshow(h)
end
it's not working at all . Thanks in advance for help in edit the code.

댓글 수: 3

KSSV
KSSV 2019년 9월 4일
Why you want to run a loop and count? YOu have functions to do that..read about hist.
Brave A
Brave A 2019년 9월 4일
it might a mistakes.
I tried to implement what questions asked, any help?
Brave A
Brave A 2019년 9월 4일
I don't want his function becaue I have colored pictured and I want to show in gray. the first part of my code is correct but the second part , is where I am struggling .

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

 채택된 답변

Bruno Luong
Bruno Luong 2019년 9월 4일
편집: Bruno Luong 2019년 9월 4일

0 개 추천

% Test data
A = imread('ngc6543a.jpg');
red=A(:,:,1);
green=A(:,:,2);
% h = histcounts2(green,red,256); % compute
% or plot
histogram2(green(:),red(:),256);

댓글 수: 4

Brave A
Brave A 2019년 9월 4일
i don't want to use histogram function. would you plase look to the requiremnt and my code. So in my code first part is correct but the problem is in the second part. the result should be in gray
Brave A
Brave A 2019년 9월 4일
you can say I need to implement the function instead of using functions does that for me :)
Bruno Luong
Bruno Luong 2019년 9월 4일
편집: Bruno Luong 2019년 9월 4일
Yeah because the loops obviously are wrong. It come down to understand what is an histogram. If it's homework, then I can't help you more.

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

추가 답변 (1개)

Bruno Luong
Bruno Luong 2019년 9월 4일
편집: Bruno Luong 2019년 9월 4일

0 개 추천

% Test data
A = imread('ngc6543a.jpg');
red=A(:,:,1);
green=A(:,:,2);
h = accumarray([green(:),red(:)]+1,1,[256 256]);

카테고리

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

태그

질문:

2019년 9월 4일

댓글:

2019년 10월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by