Joint Histogram 2 D
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brave A
el 4 de Sept. de 2019
Comentada: Brave A
el 29 de Oct. de 2019
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 comentarios
Respuesta aceptada
Bruno Luong
el 4 de Sept. de 2019
Editada: Bruno Luong
el 4 de Sept. de 2019
% 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 comentarios
Bruno Luong
el 4 de Sept. de 2019
Editada: Bruno Luong
el 4 de Sept. de 2019
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.
Más respuestas (1)
Bruno Luong
el 4 de Sept. de 2019
Editada: Bruno Luong
el 4 de Sept. de 2019
% Test data
A = imread('ngc6543a.jpg');
red=A(:,:,1);
green=A(:,:,2);
h = accumarray([green(:),red(:)]+1,1,[256 256]);
0 comentarios
Ver también
Categorías
Más información sobre Histograms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!