Why dice similarity is so low for those two images?

Please see attached images. Even in the eye seem that are very close one image to the other since they are more or less the same with different post processing values.
Yet the dice(x,y) gives me only 0.00272479564032698
where it should give me close to 1. With that number it tells me that those two have nothing in common which is not true.
What am I doing wrong?

1 Comment

Has something to do with the Bitdepth? At one pic is 8 and the other is 1.

Sign in to comment.

 Accepted Answer

Because not many of the white pixels are in the same location in the two images. Maybe you can try imregister() first to align them, and then try again.

15 Comments

So you say that bitdepth doesn't matter? This is the second example I am using. My first example from a different set was similar to it but I was getting better coefficients, such as 0.95 or 0.99. At the previous set both images had 8 bitdepth. I feel this is the wrong but I'll try your suggestion as well and let you know
Imregister will give me 1 image as output. How am I going to apply dice after? I need two seperate images
Use 2alg as the reference/fixed image, and 2pp as the test/moving image. Use imregister() to get a new aligned 2pp, then call the Dice Sorensen equation with the 2alg and the new/registered 2pp image.
Bit depth should be 1 - they should be "logical" images, not grayscale or floating point images.
I used imregister ultimately. It gave me the error
Expected input number 1, L1, to be integer-valued.
When tried to dice(x,y).
Then I changed x (the imregistered pic) to uint8 and double but still dice comes 0
Then I just put affine and optimizer + metric in the registration command and it gave me
0.11 dice, still very low
I used imshowpair to visualize both registered image and test image and I attach the outcome. As you can see, both green and purple images are very proximal to each other. I cannot get 0 for dice. I believe it is something else.
What happenes if I change the bitdepth of the image? Will it change anything?
I changed both images to 8 bitdepth but still dice comes 0.
I am going to get mad. Any explanation for this please?
What do you call the bitdpepth of your images? They're binary images (0/1), so as Image Analyst said, the bitdepth is effectively 1 (pixel is on or off), regardless of what class you're using to store the 0s and 1s. Whether you use 1, 8, 16, 64, or 5 millions bits to store 0 and 1, you still only have 2 values.
Yes Guilaume. However, this is not the case for my issue. I get dice zero values no matter what and both my images are identical.
Like I said the reason for 0 DS coefficient is that the images are not well aligned, and the coefficient is telling you exactly that. If you want to align them and try again, you can do that but it seems like you're telling me that imregister wants uint8 images, so cast them to uint8, align them with imregister, then cast them back to logical by thresholding at 0.5 or im2bw(), then compute the DS coefficient.
I tried again using the im2bw() and dice now gives me the error
The logical indices in position 1 contain a true value outside of the array bounds.
Actually, I used Structural Similarity Index and I got very satisfactory results. Can you please explain me the differences between SSIM and DICE? Thanks
DICE looks at the percentage of overlap bewtween two binary images. SSIM works with grayscale images and does not require any sort of alignment since it's based on bulk measurements like mean and standard deviation so the objects could be anywhere.
So I might stick with SSIM. I believe it is more accurate for my occasion. Thanks Image Analyst
You might also want ot check out htis Universal Image Quality Index:

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!