7

I want to search for similar areas in two images, but I don't know what works best. The areas are not scaled or transformed in any way, but may appear anywhere in both images (I want to know where). There is other stuff around them.

This is an example of what i want:

two images with overlap showing

How can I do this?

Jongware
  • 22,200
  • 8
  • 54
  • 100
Vogel Vogel
  • 311
  • 1
  • 4
  • 12
  • 1
    I'm not an expert on this, but I think this kind of algorithm is heavily dependent on the format of the images. You plan on working on a particular format, or you need it to be general? – Desaroll Dec 20 '14 at 23:30
  • Hmm - your example removes the bit of light blue in the right bottom corner. Is that still considered "the same" then? I.e., is the rectangular space relevant? – Jongware Dec 20 '14 at 23:31
  • @Jongware: I only care about coordinates. Consider it being cropped out of image 2 by using the coordinates in image 2 :) And yes, i'm only searching for rectangles. – Vogel Vogel Dec 20 '14 at 23:34
  • Yes, and that picks up a bit of blue. So the *exact* rectangles are not the same. – Jongware Dec 20 '14 at 23:34
  • This could be anything from trivial to insanely hard depending on what the images look like... – user541686 Dec 20 '14 at 23:35
  • @Desaroll: It doesn't NEED to be general, i could convert the images to any format before searching if that somehow helped :) – Vogel Vogel Dec 20 '14 at 23:35
  • @Jongware: You are right of course. It's okay if they had to be perfect though. The example isn't exactly correct then. – Vogel Vogel Dec 20 '14 at 23:38
  • Are you working on any specific language? You don't mention any. – Desaroll Dec 20 '14 at 23:43
  • @Desaroll: I'm working with C++ but the language doesn't matter, i could "translate" it... – Vogel Vogel Dec 20 '14 at 23:50
  • 1
    I edited your sample image to better reflect what you state. However, the question is still too general. (1) The white background is *extremely* significant in this image -- color sampling ought to work quite well, but for these images only. (2) The red circle is not exactly the same in the two images. The one in Image 2 is 2 pixels higher. How "similar" do the rectangles need to be? – Jongware Dec 21 '14 at 00:18
  • @Jongware: They are not scaled or anything, but may be not pixel perfect (because of antialiasing and stuff). – Vogel Vogel Dec 21 '14 at 00:25

1 Answers1

3
  1. segmentate image

    To obtain bound rectangles/polygon/mask of found areas

  2. per each region compute

    • histogram
    • FFT or DCT and filter out unsignificant data (mostly high frequencies ... similar to JPEG comprimation)
    • size (width,heigth,area,perimeter length...)
  3. find matches

    So compare each regions between images. Handle data from #2 as single dataset and compute the similarity between compared regions based on one from the following:

  4. for specific images you can create own custom comparison

    • for example here is mine for OCR
    • if you want the same size then you can easily add comparison of the sizes +/- some treshold
  5. to improve precision

    You can divide each region to few subregions and compute #2 also for them to have more robust dataset but beware of the rotations.

    Also if you segmentation is based on color homogenity coefficient then you can also include that to the dataset

  6. rotated images

    For that you need use features independend on rotation like:

    • histogram
    • color homogenity
    • use shapes for subregions invariant to rotation like co-centric circles ...

    Or find base feature/edge and rotate one image to match the other one position ...

  7. polygons

    For polygon images you can vectorise image back to vector form and then use any polygon comparison algorithm

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380