Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Tanimoto Coefficient using Matlab

Subject: Tanimoto Coefficient using Matlab

From: Gomathi C

Date: 4 Mar, 2012 10:11:12

Message: 1 of 2

I need to calculate Tanimoto Coefficient. I don't know what's wrong in my code. I have 2 nearly similar images. But the value obtained using my code indicates that the two images are highly dissimilar. Kindly help me with my code.

%Tanimoto coeff
I=imread('sliver3.jpg');
J=imread('ref5.jpg');
figure,imshow(I),title('Original');
figure,imshow(J),title('Reference');
inter=intersect(I,J,'rows');
uni=union(I,J,'rows');
si=size(inter);
su=size(uni);
tc=si/su

Subject: Tanimoto Coefficient using Matlab

From: Roger Stafford

Date: 4 Mar, 2012 21:37:13

Message: 2 of 2

"Gomathi C" wrote in message <jivf40$bc3$1@newscl01ah.mathworks.com>...
> I need to calculate Tanimoto Coefficient. I don't know what's wrong in my code. I have 2 nearly similar images. But the value obtained using my code indicates that the two images are highly dissimilar. Kindly help me with my code.
>
> %Tanimoto coeff
> I=imread('sliver3.jpg');
> J=imread('ref5.jpg');
> figure,imshow(I),title('Original');
> figure,imshow(J),title('Reference');
> inter=intersect(I,J,'rows');
> uni=union(I,J,'rows');
> si=size(inter);
> su=size(uni);
> tc=si/su
- - - - - - - - - -
  Your use of 'intersect' and 'union' is inappropriate for determining a reasonable similarity between images, in my opinion.

  The 'intersect' call with 'rows' will return only those rows in which an entire row of I is identical to corresponding elements of an entire row of J. However, if two rows are identical between I and J except for a single element, or when one row is shifted by a single element relative to the other row, this 'intersect' call would completely ignore such an important similarity.

  Also when you calculate 'si' your result is a vector with two elements, the number of common rows and the number of elements in each row and is not in accordance with the intent of tanimoto's coefficient numerator.

  The use of 'union' with 'rows' here is even less appropriate. It returns all rows from both I and J except that possible repetitions are avoided. This is worlds away from the meaning of the denominator in the Tanimoto coefficient.

  True similarity between images is something that requires a very sophisticated processing of the image data and takes into consideration the possible need for realignment and other pattern recognition aspects of the images. It is not easily come by, certainly not with five lines of matlab code.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us