How to generate Similarity Index

We are trying to assess the similarities between lesions (dark-ish blobs in the center) of two eyes of a single patient. Sometimes - they are exact mirrors of one another (the first example) and sometimes they differ a bit more in size/shape (the second example). We are seeking any idea or suggestion to generate a "similarity index" based on the shape and size of the lesions between the two eyes: 0 being totally different and 1 being the same. Any help would be great - thank you! Jeong

Hi @jwpak,

Welcome to the forum!

As is often the case, there’s not an “easy answer.” You will likely want to perform some variation of the following steps:

  1. Image registration to remove differences in spatial location / orientation.
  2. Image segmentation to determine the part of the image over which you want
  3. Compute similarity over the segmented regions, e.g. (Sum of squared differences, Normalized Cross Correlation, or Mutual Information)
  4. Some other analysis to get “shape” differences

You may even be able to skip step (2), but that means that you won’t just be comparing differences between lesions, but between everything (blood vessels, fovea, etc…).

Below are assorted thoughts on some tradeoffs you’ll need to consider:

For step (1), you can do a rigid, (or flip + rigid) transform to align things, but then when you do step (3), your image intensity is mixed up with “shape.” To get “shape” variation you may need to do some analysis on your segmentation. (Analysing “shape” is hard, btw)

Alternatively, you can do a warping alignment for step (1). This is “better” in that you don’t have “shape” confounding your intensity comparison. But warping alignment is harder to do, and that means you could be introducing variability that represents your in-ability to warp repeatably. It also means that to get “shape” differences, you’ll need to analyze the properties of the transformation not the properties of the *image.

There’s no one answer, and in the end, you will have to decide what differences you care about most, what variables you need to control for, and what variables you are willing to tolerate as “confounds”.

Good luck!


Thanks John for your insights and suggestions. It is a lot to digest!

The shape is more interesting and important variable than size to consider. The mirror image is what makes this subgroup stands out and we want to find a way to “quantify”. We will try out based on your suggestions and see what questions we have. Thanks! Jeong


I’m wondering if there is a plug-in or script available in IJ/Fiji that computes SSD (or RMSE) between two images? Also, is there some kind of Mutual Information Score that can be estimated?

I found this thread (Measure mutual information in a video stack) in the forum, but nothing else.

Mauro Morais

1 Like

Hi @mauroccm,

Welcome to the forum,

It’s easy to make a script that computes ssd.

Mutual information is tricker of course. Here’s some code that does it, but to use this script (which uses that code) in Fiji, it takes a little extra work at the moment to install the code.


Edit: You can also learn more (and use) sklearn’s nmi implementation



Just a question from a very naive individual regarding such analyses… but if things like shape/size of these lesions is the main criteria (as opposed to spatial location, intensity, etc.) - wouldn’t it be ideal to then solely base the analysis on segmented, binarized images? Just found the Shape Filter plugin in ImageJ … perhaps such a tool could be used as a starting point to get shape features for each image?

These are colleagues of mine that I’m trying to assist in building a workflow… so thank you all for responding with insight on this!



You’re right, it would be a good idea to use the segmentation and only the segmentation, in this case.

Nice find! That looks like a great place to start, and may be good enough to do the whole job!