Why I got error when I used Jaccard similarity coefficient?
5 views (last 30 days)
Show older comments
I used the following aklgorithm to evaluate the jaccarrd index:
gT= imread('crack .png');
o=imread('outPut .png');
similarity = jaccard(o, gT)
figure
imshowpair(o, gT)
title(['Jaccard Index = ' num2str(similarity)])
but I got The following error message:
Error using jaccard
Expected input number 1, A, to be one of these types:
logical, double, categorical
Instead its type was uint8.
Error in
jaccard>@(x,name,pos)validateattributes(x,{'logical','double','categorical'},{'real','nonempty','nonsparse'},mfilename,name,pos)
(line 118)
validateInput = @(x,name,pos) validateattributes(x, ...
Error in jaccard (line 123)
validateInput(A,'A',1);
Error in Gtruth1 (line 21)
similarity = jaccard(o, gT)
Thus, how can i fix this error, especially I am new biggener in matlab and I am trying to evaluate the similarity between groundTruth image (crack.png) and the resulted image from my model (outPut.png)?
0 Comments
Answers (1)
Shreeya
on 16 Jan 2024
The jaccard function in MATLAB expectes the input argument images of type logical. The error thrown suggests that the images are of datatype uint8. The documentation linked below can help you understand the usage of the function:
To convert the images to a logical format, you can use the code below:
gT_logical = gT > threshold;
This code is sourced from the following MATALB answer. You can refer to the discussion for more details:
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!