Clear Filters
Clear Filters

How to calculate the precision and recall ( determine FP and FN) for image detection based on image segmentation?

7 views (last 30 days)
IF i used jaccard index and I got value of jaccrad =0.9 if I assume my threshold is 0.5 so if jaccard value >0.5 will be TP and if less will be FP
what about FN?

Answers (1)

Image Analyst
Image Analyst on 20 Nov 2023
Jaccard index is related to how much a "ground truth" binary image overlaps your "test" image. According to the help "similarity = jaccard(BW1,BW2) computes the intersection of binary images BW1 and BW2 divided by the union of BW1 and BW2, also known as the Jaccard index."
So using your definition, you're saying that if they overlap by more than 50%, it detected it correctly -- it's a True Positive. And you're saying that if they overlap by less than 50% it's a False Positive because even though they might overlap some, it's not enough to be considered correct.
A false negative would be if you said there was nothing there (gave a Negative) when there actually was something there.
Look at the different possible cases:
bw1 = true(2,2); % Something there.
bw2 = false(2,2); % Nothing there.
bwHalf = logical([1,1;0,0]);
similarityIndex = jaccard(bw1, bw1)
similarityIndex = 1
similarityIndex = jaccard(bw1, bw2)
similarityIndex = 0
similarityIndex = jaccard(bw2, bw1)
similarityIndex = 0
similarityIndex = jaccard(bw2, bw2)
similarityIndex = NaN
% Using half overlap
similarityIndex = jaccard(bw1, bwHalf)
similarityIndex = 0.5000
similarityIndex = jaccard(bw2, bwHalf)
similarityIndex = 0
Case 2 or 3, where the ground truth had something while the test/prediction said there was nothing, both give a Jaccard index of 0. That would be a False Negative -- it said it was negative but it was false because it should have said it was positive.
  12 Comments
yasmin ismail
yasmin ismail on 23 Nov 2023
@Image Analyst I understoodd the ROC
but the FN not yet, and I said I have not ground truth for TN
The cases you discussed above are :
bw1 = true(2,2); % Something there.
bw2 = false(2,2); % Nothing there.
bwHalf = logical([1,1;0,0]);
similarityIndex = jaccard(bw1, bw1)
similarityIndex = 1
similarityIndex = jaccard(bw1, bw2)
similarityIndex = 0
similarityIndex = jaccard(bw2, bw1)
similarityIndex = 0
similarityIndex = jaccard(bw2, bw2)
similarityIndex = NaN
% Using half overlap
similarityIndex = jaccard(bw1, bwHalf)
similarityIndex = 0.5000
similarityIndex = jaccard(bw2, bwHalf)
similarityIndex = 0
Case 2 or 3, where the ground truth had something while the test/prediction said there was nothing, both give a Jaccard index of 0. That would be a False Negative -- it said it was negative but it was false because it should have said it was positive.
That what you said about FN before , the similarity index =0, then you said :
FN = sum(binaryImage, 'all') > 0 && max(groundTruthBinaryImage) == 0;
I get confused and cannt understand it?

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!