comparison of two histograms using pdist2

17 ビュー (過去 30 日間)
Muhammad Ali Qadar
Muhammad Ali Qadar 2013 年 8 月 23 日
コメント済み: Devarshi Patel 2018 年 12 月 10 日
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
  1 件のコメント
RANJITHA H V
RANJITHA H V 2015 年 3 月 31 日
pdist2 is showing error

サインインしてコメントする。

採用された回答

Anand
Anand 2013 年 8 月 23 日
You almost got it right. Just transpose the histograms. So you're last command should be
d = pdist2(c1',c2');
  8 件のコメント
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 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by