Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is one image in another?
Message
 
To
18/03/2004 13:02:54
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
00887604
Message ID:
00887671
Views:
5
Hi Mike,

If you go back 20 years, this, pretty much falls into the realm of Digital Signal Processing, and takes me back to my senior year in college. Nowadays, I think it'd be called "Image processing".

I don't know the exact algorithm to use for this (I have a feeling that this sort of thing already exists out there).

If I had to do it from scratch, here's what I'd do.

I'd pixelate the image (don't know if that's the right term though).

Take blocks of 50 x 50 pixels, and convert them into a single pixel, whose value is the average of the values of the 2500 pixels you just took. You will need to find a way to convert your image into an array or something vfp can handle natively. Arrays seem to be a good option because vfp's so fast dealing with them, so a bit of strtofile() will be needed.

Do a first comparison this way, rotating the image 180 degrees to be sure that the image hasn't been flipped. See if the small image is SIMILAR (you have to set criterias for this) to areas of the same size from the large image.

If you find one or more areas that seem similar, repeate the process, but this time pixelate using 25x25 blocks instead of 50x50.

Then keep repeating until you get the comparison made on images with no pixelation.

For the sake of simplicity, instead of starting with a 50x50 area, start with a number that you can reduce through iterations to 1x1. For example, 64x64 means you'll be repeating the process 6 times if you keep halving the size of the blocks, or you can use multiples of 3, whatever works for you, just use a number that isn't prime and doesn't have prime factors so your code can simply be iterated n times.

I just ran a quick search for "image within image" and came up with an answer fairly similar to mine in the comp.graphics.algorithms newsgroup. Visit www.deja.com and do some searches. It's an interesting topic.

Have fun!

Alex

>Hi all
>
>Suppose I have an image obtained from a fax, scanner or digital camera. Can anyone think of a way to have FoxPro determine if a second image is part of the larger image?
>
>There is the possibility that the scanned image has turned in the scanner. If that happened, the only way to match would be to attempt to rotate the second image until a match was found. If the scanner cut off the top of the larger image, the second image would have to be moved up too. I'll be performance conscious and suggest it only look at part of the document within a 10% margin and plus/minus 10 degrees.
Low-carb diet not working? Try the Low-food diet instead!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform