Object matching



Happy new year !!
I will build a python script that search for an object given in a fluorescence microscopy image.
I am looking for recommendations regarding the algorithm to be used and things to avoid.
Thank you for your advices.


Good day!

You don’t provide sufficient details …

If the objects in question are always of the same size and orientated in the same way, I would suggest cross-correlation. If the objects can have arbitrary orientation and differ in size things become rather involved.

Some typical images would greatly help!




Hi herbie ! thank you for your answer…
Yes the objects have arbitrary orientation and differ in size.
For example i select a glomerulus (picture 1) from the sample and see if there is other glomerulus in the sample (picture 2).



Thanks for the images.

Whatever approach you use, I’m sceptic about reliable results.

The human eye is so much better regarding such tasks. Start doing it manually and don’t lose time by looking for automatic ways that in the end will turn out producing unsatisfactory results.

Have success



Optimistic :smile:
I will continue my research.


Based on the discussion above: might be a job for machine learning. Depends how many images you have available for training, and how many objects you need to identify. If a small number, I agree with @Herbie that doing it by hand may be easiest. If a large number, it is worth researching the available tools for object classification—maybe start by looking at CellProfiler Analyst.


I got great results with the cvMatch_Template plugin that has been ported to IJ.




@rondespain thank you for your answer !! But as you can see. there is other glomerulus that imajej was not able to identify. did you used the multimatch option ??


I set it for a single match. Run the code and loosen up on the match criteria.



My favorite algorithm for matching is normalized cross correlation. It takes care of brightness differences via normalization and uses correlation for the match.



My favorite algorithm for matching is normalized cross correlation.

It doesn’t cope with scale changes and rotations and that’s what is important for the OP. At least he told us so …




Great, but the main goal of the algorithm that i want to build is to find the other similar membrane in the image, at this point with imagej you are only succeeding to find the same object and not the similar ones…

did you changed the size of the object(template) because it’s supposed to be bigger…


I did change the size since correlation can’t deal with size changes (unless you unzoom first). If your template is to be zoomed and rotated you should not use correlation if you don’t know how to get the images aligned and scaled. There are several registration algorithms within IJ that you could try in advance of correlation matching. Look for distinguishing features within the target, isolate and feature match to them. I don’t know the field well enough to suggest what might be similar features among your target class.

Good luck


Thank you rondespain for your efforts and advices. let me know whenever you have any idea…