Can I give the program a 'master' image to search for?



Hi there!

I was just wondering, is it possible to give the software a ‘master’ image to search for, and then measure the size of all the iterations it finds throughout the sample images?


I think what you’re describing is called template matching, but perhaps you could elaborate? It sounds like each image has one and only one item and you want to measure its size? Can you provide an example image?


no no, there could be multiple items per image - think of it like optical character recognition where it looks for a character and measures it


@Anne_Carpenter is correct that this is called template matching; CellProfiler 3.0 has a module called MatchTemplate based on a skimage function that can do something similar (In that demo, they’re only looking for the closest matching coin, but you can easily imagine that if they’d set the threshold differently it’d be trivial to find all the coins).

It’s not going to do a perfect job, based on my experience with the module (the biggest caveat is that it’s not size or rotation invariant, so you need your objects to be relatively round and kinda similar in size), but it’d probably work well enough to find centers of all the objects that you could then use as seeds to get a better segmentation (which you could then use to measure size).


I had no idea! Giving it a shot now - do you know why the template and the sample images need to be the same size?


They don’t (and in fact should not be). You don’t need to drag and drop your template image into the images panel at the beginning- you’ll call it specifically in the MatchTemplate module.

If you’re confused or getting an error, can you post it here?


I’ll post it when I get a chance; it just throws an error anytime I try and use it, it either says that the template isn’t the same size or less than the sample images, or that the sample images aren’t the same size or greater than the template. I’ve even tried using the same image for the sample and template, and it still comes up with this error :frowning: