display image similarity using pie and bar chart

조회 수: 1 (최근 30일)
nat larsey
nat larsey 2020년 5월 28일
댓글: nat larsey 2020년 6월 1일
Hi guys, i want to know whether it is possible to display the similarities between 2 or more images using pie chart and bar chart in percentages.

채택된 답변

Subhadeep Koley
Subhadeep Koley 2020년 5월 28일
I have used the ssim function to measure the similarity between to images. ssim metric value lies in the range of [0, 1]. Higher ssim value represents higher similarity. Therefore, I have used 1-ssimVal to caculate the dissimilarity. Refer the code below,
close all; clc;
% Read the original image
img = imread('cameraman.tif');
% Adding noise in the original image for demo
noisyImg = imnoise(img, 'gaussian', 0, 0.05);
% Calculate Structural Similarity Index (SSIM)
ssimVal = ssim(img,noisyImg);
% (1-ssimVal) will give the dissimilarity
values = [ssimVal, (1-ssimVal)];
% Display results
figure('units', 'normalized', 'outerposition', [0 0 1 1])
subplot(2, 2, 1)
imshow(img)
title('Original image')
subplot(2, 2, 2)
imshow(noisyImg)
title('Noisy image')
subplot(2, 2, 3)
pie(values)
labels = {'Similarity(%)', 'Dissimilarity(%)'};
legend(labels, 'Location', 'bestoutside')
title('Similarity pie chart')
subplot(2, 2, 4)
xValues = categorical({'Similarity(%)', 'Dissimilarity(%)'});
yValues = [ssimVal (1-ssimVal)].*100;
han = bar(xValues, yValues);
xtips1 = han(1).XEndPoints;
ytips1 = han(1).YEndPoints;
labels1 = string(han(1).YData);
text(xtips1, ytips1, labels1, 'HorizontalAlignment', 'center',...
'VerticalAlignment', 'bottom')
title('Similarity bar chart')
Hope this helps!
  댓글 수: 2
Subhadeep Koley
Subhadeep Koley 2020년 5월 28일
@ nat larsey It is not clear what you exactly meant by 'compare'. SSIM compare how visually similar two images are. You want something like Cross Correlation metric between those images?
nat larsey
nat larsey 2020년 6월 1일
yes sir

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by