Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Similarity measure between two images

I am currently implementing image segmentation on MATLAB . I have two implementations.

  1. The image is segmented into two regions - foreground and background.
  2. The image is segmented into more than two regions - suppose 3 segmented regions or 4.

I am trying to compute the similarity measure between the segmented image and the ground truth (manual segmented images) by using the dice coefficient or the Jaccard Index. This works well for the segmented images that have been divided into two regions. This is implemented by the following code.

dice = 2*nnz(segIm&grndTruth)/(nnz(segIm) + nnz(grndTruth))

Click Here

This expects segIm and grndTruth to be of the same size. They must also be numeric or logical.

However I have not been able to find a way to apply this measure for comparison of similarity for multiple - region segmented images. Can anyone tell me how I can use the dice coefficient in my application ?

EDIT: With respect to nkjt's suggestions I have done a basic implementation and am giving the results below. Please feel free to upgrade the code anyone for better accuracy.

I am considering two images in the form of two matrices. A is the segmented image and B is the manual ground truth. The matlab code for the above suggested implementation is given below. Please check and do give your thoughts.

A=[1 2 3 4;1 2 3 4;1 2 3 4;1 2 3 4]
B=[1 3 4 4;1 1 3 4;1 2 3 4;1 2 3 1]
%//First Suggestion
dice = 2*nnz(A==B)/(nnz(A) + nnz(B))
%//2nd Suggestion
A1=(A==1);B1=(B==1);
A2=(A==2);B2=(B==2);
A3=(A==3);B3=(B==3);
A4=(A==4);B4=(B==4);
dice = (2*nnz(A1&B1)/(nnz(A1) + nnz(B1))...
        +2*nnz(A2&B2)/(nnz(A2) + nnz(B2))...
        +2*nnz(A3&B3)/(nnz(A3) + nnz(B3))...
        +2*nnz(A4&B4)/(nnz(A4) + nnz(B4)))/4

Please Note : I am also interested to know if Hausdorff Distance Measure can be applied in this case for both the 3 phase and 4 phase segmented images??

EDIT: I do have a new query . If suppose the image has 4 regions and it has been correctly segmented in this manner as shown in the example below: If now different intensity values are used to denote the different regions , then using Dice coefficient the two segmented results will give different results. For Segmented Reg 1, I have dice = 1 ** and for **Segmented Region 2, I have dice = 0.75. But both the results are accurate. How can I modify my code such that the segmented results will reflect the answer of the dice coefficients ?

enter image description here

like image 714
roni Avatar asked Oct 03 '22 11:10

roni


People also ask

What is similarity measure in image processing?

An similarity measure is a measure of correspondence between two images. If the similarity measure is maximal, the images are considered to be correctly aligned.

How do you find the similarity measure between two sets?

Typically, the Jaccard similarity coefficient (or index) is used to compare the similarity between two sets. For two sets, A and B , the Jaccard index is defined to be the ratio of the size of their intersection and the size of their union: J(A,B) = (A ∩ B) / (A ∪ B)

How do you find the similarity between two objects?

To calculate the similarity between two examples, you need to combine all the feature data for those two examples into a single numeric value. For instance, consider a shoe data set with only one feature: shoe size. You can quantify how similar two shoes are by calculating the difference between their sizes.


2 Answers

The work of Arbel´aez et al. describes several methods to compare results of image segmentation algorithms. See section 3.1 and its sub-sections.

I believe some Matlab code can be found in thier project's webpage.

The Berkeley segmentation dataset (bsds500) is a well established benchmark in the image segmentaiton community.

like image 117
Shai Avatar answered Oct 11 '22 10:10

Shai


You might want to look into measures designed for segmentation, such as Normalized Probabilistic Rand.

However, I can see two possible ways of doing something quick with your existing code.

1) Instead of using logical images and &, use:

dice = 2*nnz(segIm==grndTruth)/(nnz(segIm) + nnz(grndTruth));

Both segIm and grndTruth here should be numerical (ideally integer with foreground regions having values of 1,2,3... etc).

2) Produce a set of binary images out of both segIm & grndTruth for each foreground area, and define a dice coefficient for each.

like image 33
nkjt Avatar answered Oct 11 '22 09:10

nkjt