why I got very low IoU compaired with ssim?

4 vues (au cours des 30 derniers jours)
yasmin ismail
yasmin ismail le 19 Oct 2023
%%SSim
A = imread('new7027-157.png');
BW_groundTruth =imread('Label7027_157.png');
[ssimval,ssimmap] = ssim(A,BW_groundTruth);
imshow(ssimmap,[])
title("Local SSIM Map with Global SSIM Value: "+num2str(ssimval))
0.93
%%IoU
A = logical(imread('new7027-157.png'));
BW_groundTruth =logical(imread('Label7027_157.png'));
similarity = jaccard(A, BW_groundTruth)
similarity =
0.2822
I created GroundTuth by using Image segmenter App and export it to work space and i got high result 0.93 when I applied ssim , then i used jaccrad index(IoU) and I got 0.2822 , why I got very law result although both images seem same by eye vision, how to fix it, is it related to the way of creating groundtruth or I missed something to do after labeling before calculationg the similarity? can you help me to fix it please?
I attached the original image (70027-157.jpg) which used in Image segmenter App for labeling, the labeled image is(label7027-157), the the model output(new7027-157) which is needed to be evaluated

Réponses (1)

Maneet Kaur Bagga
Maneet Kaur Bagga le 11 Oct 2024
Hi,
After inspection of your images, I can see that both the "ground truth" and "model output" are in "grayscale" format and not in "binary" form that is the pixel values are not strictly "0" and "1". The "Jacard Index" requires binary images (logical arrays) and therefore this difference in pixel intensity is resulting in low similarity score using "IOU".
To resolve the issue you need to apply a threshold to both the model output and the ground truth to convert them into binary masks before computing IOU. You can set the pixel value greater than "0" as "1" (foreground) and others to be set as "0" (background).
Also, the low IOU score with the high SSIM suggests that the overall structure and visual similarity of the two images are good but the actual pixel-wise overlap is not close. This could be due to small misalignments or differences in the segmentation boundaries between the ground truth and model output.
Please refer to the following MathWorks documentation for more understanding:
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by