HOW TO CALCULATE THE DICE SIMILARITY OF THE IMAGES SUBPLOT.

조회 수: 1 (최근 30일)
mohd akmal masud
mohd akmal masud 2021년 10월 20일
댓글: yanqi liu 2021년 10월 27일
Hi all, I have 2 data set logical images(binary images). EACH DATA SET HAVE 23 IMAGES. I want to check the dice similarity.
Below is the code for aorigional images.
%% first, read the image data and labelled images
clc
clear all
dataSetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
imageDir = fullfile(dataSetDir,'labelledimages');
imds = imageDatastore(imageDir);
% view data set images origional
figure
for i = 1:23
subplot(5,5,i)
I = readimage(imds,i);
imshow(I)
title('training labels')
end
The the second one images code is below
%% second, read the binary images after segmentation
dataSetDir1 = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
imageDir1 = fullfile(dataSetDir1,'bnwaftersegmentation');
imds1 = imageDatastore(imageDir1);
% view data set images origional
figure
for ii = 1:23
subplot(5,5,ii)
II = readimage(imds1,ii);
imshow(II)
title('binary labels')
end
Then i used code below to know the dice similarity, but the answer is 0
similarity = dice(I, II)
similarity =
0
But I try test just one image (let say image number 11), its work.
s = imread('11.png');
d = imread('11.png');
similarity = dice(s,d)
similarity =
0.15119
ANYONE CAN HELP ME HOW TO CALCULATE THE TOTAL DICE SIMILSRITY FOR ALL 23 IMAGES

채택된 답변

yanqi liu
yanqi liu 2021년 10월 26일
%% first, read the image data and labelled images
clc
clear all
dataSetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
imageDir = fullfile(dataSetDir,'labelledimages');
imds = imageDatastore(imageDir);
% view data set images origional
Is = [];
figure
for i = 1:23
subplot(5,5,i)
I = readimage(imds,i);
Is{end+1} = I;
imshow(I)
title('training labels')
end
%% second, read the binary images after segmentation
dataSetDir1 = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
imageDir1 = fullfile(dataSetDir1,'bnwaftersegmentation');
imds1 = imageDatastore(imageDir1);
% view data set images origional
Is2 = [];
figure
for ii = 1:23
subplot(5,5,ii)
II = readimage(imds1,ii);
Is2{end+1} = II;
imshow(II)
title('binary labels')
end
%% compare the dice similarity for every slice, like 1 with 1, 2 with 2, 3 with 3....and so on till 23 with 23..
similarity = [];
for i = 1 : 23
similarity(i) = dice(Is{i}, Is2{i});
fprintf('the dice similarity for %d with %d is %.3f\n', i, i, similarity(i));
end
  댓글 수: 2
mohd akmal masud
mohd akmal masud 2021년 10월 26일
tq sir, its work.
sir, how to buy your book?
yanqi liu
yanqi liu 2021년 10월 27일
thank you,may be amazon
https://www.amazon.cn/dp/B086ZXVX2K/qid=1635297216

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by