hi, I am having two Images I wanted compare these two Images by histograms I have read about pdist that provides 'chisq' but i think the way i am doing is not correct, and what to do to show the result afterwards because this is giving a black image.
i1=imread('blue_4.gif');i1=i1(:,:,1);
[c1,n]=imhist(i1);
c1=c1/size(i1,1)/size(i1,2);
i2=imread('blue_5.jpeg');i2=i2(:,:,1);
[c2,n2]=imhist(i2);
c2=c2/size(i2,1)/size(i2,2);
d=pdist2(c1,c2,'chisq');
please give me a working example thanks

 채택된 답변

Anand
Anand 2013년 8월 23일

3 개 추천

You almost got it right. Just transpose the histograms. So you're last command should be
d = pdist2(c1',c2');

댓글 수: 8

Anand, Taking transpose gives just one single value, otherwise it gives 255*256 Array, I think for Compared histogram there should be an array. What you think waiting for you suggestion
Anand
Anand 2013년 8월 26일
Why do you think there should be an array when you comparing the distance between 2 histograms?
The chi-square distance between two distributions (normalized histograms in this case) is expected to be a single number and is useful in comparing how similar the histograms of the two images are. At least, that's how I used it in my research.
When you do not transpose the histograms, pdist2 interprets it differently and gives back pair-wise distances for the elements in the histograms. That's not what you want.
@Anand, thank you for Clarification, can you tell me what this value exibits and if this value could be used as threshold to for a test image
Anand
Anand 2013년 8월 28일
The smaller the value, the more similar the histograms of the two images are. So, this value can be used as an indicator of how similar the images are. Note that this is a primitive indicator.
You can set a threshold on this value and find the images most similar to the image being compared against.
Quite Logical thanks a lot
bhagya
bhagya 2014년 10월 15일
superb
Sashank
Sashank 2017년 11월 19일
I am beginner. Please guide me about How can I know how much similar two images are ?
Devarshi Patel
Devarshi Patel 2018년 12월 10일
How can we do this for RGB histogram?

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

추가 답변 (1개)

Raghunandan
Raghunandan 2014년 10월 31일
편집: Raghunandan 2014년 10월 31일

0 개 추천

Just wanted to let you know that pdist2 in MATLAB uses 'Euclidean' distance by default. If you are looking to get 'ChiSquare' distance, please use the code found here.

댓글 수: 1

ndoum ekanga  steve willy
ndoum ekanga steve willy 2015년 11월 27일
편집: ndoum ekanga steve willy 2015년 11월 27일
But this doesnt give me any output, i cant even see the similarity.
% read two images Im1 = imread('ckt_1.tif'); Im2 = imread('ckt_3.tif');
% convert images to type double (range from from 0 to 1 instead of from 0 to 255) Im1 = im2double(Im1); Im2 = im2double(Im2);
% Calculate the Normalized Histogram of Image 1 and Image 2 hn1 = imhist(Im1)./numel(Im1); hn2 = imhist(Im2)./numel(Im2);
% Calculate the histogram error
f = sum((hn1 - hn2).^2); f; %display the result to console

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

카테고리

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

질문:

2013년 8월 23일

댓글:

2018년 12월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by