how to compare ground truth image with segmented image?

조회 수: 11 (최근 30일)
tashu Dabariya
tashu Dabariya 2019년 7월 29일
답변: Leandro Hidalgo Torres 2019년 10월 25일
BW2=imread('C2.png'); %segmented image
figure,imshow(BW2)
BW=imread('001_mask.png'); %groundtruth-image
figure,imshow(BW)
% mask = false(size(BW2));
% mask(25:end-25,25:end-25) = true;
% BW = activecontour(BW2, mask, 300);
similarity = jaccard (BW2, BW)
figure
imshowpair(BW2, BW)
title(['Jaccard Index = ' num2str(similarity)])
I am trying to find accuracy but got an error.
Undefined function 'jaccard' for input arguments of type 'uint8'.
Error in Untitled (line 8)
similarity = jaccard (BW2, BW)
what will be changed in this code?
  댓글 수: 2
Adam
Adam 2019년 7월 29일
편집: Adam 2019년 7월 29일
Do you have the Image Processing Toolbox and are you using R2017b or later (it does help a lot if you fill in the Products and Release section of the question)? What does
which jaccard
show?
Arslan Ahmed Awan
Arslan Ahmed Awan 2019년 10월 22일
You have to Install MATLAB R2017b because jaccard was introduced in Image Processing Toolbox of R2017b.

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

답변 (2개)

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2019년 10월 22일
Jaccard index is the intersection (BW.*BW2) over the union (BW|BW2) or ((BW+BW2)>0), so you can calculate directly like this
sum(sum( BW.*BW2)) / sum(sum( BW|BW2))
Accuracy is different, that is how many pixels are exactly the same (including background)
sum(sum(BW==BW2)) / prod(size(BW))

Leandro Hidalgo Torres
Leandro Hidalgo Torres 2019년 10월 25일
Hi,
Jaccard needs their arguments to be logical type. Check the data type of BW and BW2, surely they are uint8 type. If it's true, use BW=logical(BW) and the problem will be solved,
Best regards,
LH

Community Treasure Hunt

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

Start Hunting!

Translated by