Page 1 of 1

search for subimage and replace

Posted: 2012-03-28T07:03:22-07:00
by bongo
i would like to search a big image for all occureces of a smaller subimage and mark these positions.

using -subimage-search, i always just get one position of the subimage marked within the big image ;-(
there also should be a way to define a matching tolerance, as there will be some differences between the subimage and the occurences within the big image because of compression.

i would like to get all occurences of the subimage colored (or maybe marked in any other way) within the big image.

how can this be done?

thanx!

Re: search for subimage and replace

Posted: 2012-03-28T09:13:29-07:00
by whugemann
I think http://www.wizards-toolkit.org/discours ... =3&t=20426 demonstrates what you are looking for. AFAIK, you can only search for the first location of a subimage. Therefore you must perfrom your task in a loop, i.e. search for the first occurance, store its location, blank that area, store an interim image, search for the first occurance in that interim image, and so on, until the image cannot be found any more.

After that loop is finished, you can use your stored values to manipulate the original image, e.g. draw rectangles around that areas or alike. The processing will be very slow, though.

If I were you, I would look whether there is a ready-made plugin for Fiji performing this task, which I think is quite likely.

Re: search for subimage and replace

Posted: 2012-03-28T09:45:38-07:00
by fmw42
If you are on unix or windows with cygwin, you can process the second (match score) image from the compare of a small image with a larger one to find other matches using my bash unix script, maxima. See the link below.

Re: search for subimage and replace

Posted: 2012-03-28T19:31:10-07:00
by anthony
bongo wrote:i would like to search a big image for all occureces of a smaller subimage and mark these positions.

using -subimage-search, i always just get one position of the subimage marked within the big image ;-(
there also should be a way to define a matching tolerance, as there will be some differences between the subimage and the occurences within the big image because of compression.

i would like to get all occurences of the subimage colored (or maybe marked in any other way) within the big image.

how can this be done?

thanx!
Typically the map of matches, is further processed to highligh and locate 'peaks' within the image
This can be done using Speciallized Morphology or Convolution Kernels
One example is in...
http://www.imagemagick.org/Usage/convol ... ate_search


If you can give a small sample image (the image searched, and the sub-image to look for), we can help further.
Though I remember a specific 'mandrill eyes' image that Fred has used to find BOTH eyes.
Hmm yes.. From Fred's Maxima Script
http://www.fmwconcepts.com/imagemagick/maxima/index.php

This masks out findings (to remove any other nearby peak) until some limit is reached.
However with one preprocessing step using a morphology 'peaks' kernel
http://www.imagemagick.org/Usage/morphology/#peaks
you can highlight and discount all 'nearby' peaks in the one step. The result can be used as a mask into the original image to find the actual 'peak' value at that point, rather than the 'difference' gap


I have updated my notes about methods of peak finding... (give it an hour or so)
http://www.imagemagick.org/Usage/compare/#peak_finding