How to calculate the dice similarity coefficient

15 visualizaciones (últimos 30 días)
mohd akmal masud
mohd akmal masud el 12 de Oct. de 2023
Respondida: Rik el 12 de Oct. de 2023
Dear All,
Anyone know how to calculate the dice similarity my image data set as attached.

Respuesta aceptada

Rik
Rik el 12 de Oct. de 2023
Let's first see what you have in those mat files:
s1=load('prediction.mat')
s1 = struct with fields:
allBW: [130×130×90 logical]
s2=load('groundtruth.mat')
s2 = struct with fields:
allBW: [130×130×90 logical]
So you have two equal-sized binary arrays.
Ten seconds of Googling ('wiki dice coefficient') can give you this formula:
dice = 2*union of X and Y / X+Y
Now you only have to implement this in Matlab.
X = s1.allBW;
Y = s2.allBW;
X = X(:);Y = Y(:); % linearize to make notation clearer
DSC = (2*sum(X&Y))/(sum(X)+sum(Y))
DSC = 0.8806
We can check this implementation by using the other notation:
DSC = 2TP/(2TP+FP+FN)
% (for the calculation X and Y can either be the ground truth, the DSC will
% have the same value)
TP = sum( X& Y);
FP = sum( X&~Y);
FN = sum(~X& Y);
DSC = 2*TP/(2*TP+FP+FN)
DSC = 0.8806

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by