How to determine the threshold for SSIM of images?
Show older comments
I created detected crack model based on image segmenation and ssim value for my images 0.95 and above , so how to decide the threshold?
I attached the original image 7027-157 and the groundTruth(label7027-157) and the output image (new7027-157) from the created model (which is created to detect crack) to compaire with groundTruth. so if I have 100 images how can i determine the threshold for ssim?
Answers (1)
Image Analyst
on 23 Oct 2023
0 votes
You can set the threshold for whatever you want. I have no idea how you'd even use it. I'm not sure what you did. You cannot sensibly use ssim to compare any of those three images to each other - it just doesn't make sense. Just think about it. They're far too different. So setting a threshold for it would also not make sense. At best you might judge how good a job your segmenter did by comparing your ground truth to the "new" image, but even that is not good. That's because your "new Image" doesn't look like your ground truth image. It looks like it's been skeletonized so you'd have to use something like dice to compare the skeleton of your ground truth image to the "new" skeletonized image. Or else you can use dice to compare a binarized version of the ground truth image to the "new" image before you binarized it.
Again, ssim would not be used here. It's meant for comparing two similar images, such as a gray scale image and one that underwent a round trip compression and decompression for example.
12 Comments
yasmin ismail
on 23 Oct 2023
Image Analyst
on 23 Oct 2023
Your dice score is so low because the new image is only a skeleton, while the ground truth gray scale image, when you call logical(), converts all the non-zero pixels to true so it's a lot bigger. If youi're going to compare thick cracks then both should be thick cracks. If you're going to compare skeletons, then both should be skeletons. You can't mix them.
yasmin ismail
on 24 Oct 2023
Edited: yasmin ismail
on 25 Oct 2023
Image Analyst
on 25 Oct 2023
Youi'll have to zoom in and look at each pixel of the skeletons and see if they are both white at the same location. Even if it's off by just one pixel, it will affect the result. It looks like maybe 80% of your pixels are off.
yasmin ismail
on 25 Oct 2023
Edited: yasmin ismail
on 25 Oct 2023
Image Analyst
on 25 Oct 2023
You do realize that if you train a model with training images and ground truth images, and then use that trained model and run through your training images that you will not get exactly the corresponding ground truth image out, right? The more images you have and the longer you train, the closer to the ground truth you will get, but you don't want to train overly long so that you get your ground truth images out exactly, because in that case, it's merely memorizing your input images and your predicted image for an image not in your training set will quite possibly be worse than if you didn't train as long. This is the classic problem of overfitting.
yasmin ismail
on 26 Oct 2023
Image Analyst
on 27 Oct 2023
Edited: Image Analyst
on 27 Oct 2023
- Yes, by definition, you labeled them correctly because there is no other source of ground truth other than your opinion so however you labeled them, in your mind, it was labeled correctly. How could they not be?
- Yes, semantic segmentation would be the way to get your deep learning neural network model predict what you labeled, though the prediction will not match exactly of course.
- If you labeled the region(s) and trained the model, and then took one of your training images and ran it through the model, then it should create a binary image mask that is where it thinks the region is in that image. To see how well it matches up with your ground truth image you need to get a binary image of your ground truth image and that would be a binary image of the region. You can use ismember to extract the pixels with the label number, mask = ismember(labeledImage, labelNumber), or you can use simple thresholding. I would not skeletonize anything at this point. After you're satisfied that the prediction is good, then as part of subsequent analysis you might want to skeletonize, for example to get the crack length in addition to the area.
- You can compute the dice scores for your training images. What the threshold for acceptable or not acceptable is, is up to you. You may decide that if it's more than 90% overlap between ground truth and predicted that it's good enough to start using. Or you may decide that it's not good enough and you'll need to train more, either longer or (preferably) with more training images.
yasmin ismail
on 30 Oct 2023
Image Analyst
on 30 Oct 2023
See attached general purpose app that I made to train the network and predict masks using the trained network.
yasmin ismail
on 1 Nov 2023
Image Analyst
on 1 Nov 2023
You need to run the training app first and save a model .mat file. Then you can use the predict app to read that model and apply it to images.
It's possible some of my utilities might be called so you should save the utilities folder in the attachment and set a path to it.
Categories
Find more on Image Processing and Computer Vision in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!