• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finding Exact and Alphanumeric Image Matches

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:
I was hoping someone could give me some insight into finding exact image matches. I know image comparison is complex if you�re trying to find similar images, but the comparison I�m trying to do is locating an image that is exactly the same as the one I have in hand.
I have a bunch of images of differing sizes into which I inserted a logo. The logos are all exactly the same so I want to search each image, locate the x, y coordinates of the logo on that image and remove/replace the logo. I�m sure it involves comparing pixels or something, but I�m not sure how to do this. Can someone point me to an effective and quick way to locate a matching image within a picture?
Also, I know the approximate area the logo appears in all the pictures (bottom right) so is there a way to use this information to speed up the process so it doesn�t have to search the whole table.
On a related topic, there is a serial number I inserted into each of my images. Is there a way to extract these letters and numbers from a pixel/graphic representation into string/int data? I�m sure if I don�t know the exact font used I just have to make samples of each character (0-9, A-z) and use the comparison type method I asked about above. But how about if you have/know the font used? Otherwise is there a good way to go about converting alphanumeric image data? I�m sure those hidden speed guns/cameras use this type of technology to capture the license plate numbers of speeding cars these days.

Any help would be greatly appreciated. Thanks in advance!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before going into a lengthy explanation, please verify that I understand your question. It sounds like you want to determine whether or not an image has been "stamped" with your logo and, if so, find the x,y coordinate of the logo. Is that correct? Can we assume that the logo is the same size on each image (even though the images may vary in size)?
Also, I'm assuming that you want to first read the image into a Java Image object rather than looking at the raw image data. Is this correct?
 
Micho Lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the speedy reply Jon.
"Before going into a lengthy explanation, please verify that I understand your question. It sounds like you want to determine whether or not an image has been "stamped" with your logo and, if so, find the x,y coordinate of the logo. Is that correct?"
Yes, that is what I asked on the first part of the question.
"Before going into a lengthy explanation, please verify that I understand your question. It sounds like you want to determine whether or not an image has been "stamped" with your logo and, if so, find the x,y coordinate of the logo."
Again, Yes.
Is that correct? Can we assume that the logo is the same size on each image (even though the images may vary in size)?
Yes, the logo images are all exactly the same as the original.
Also, I'm assuming that you want to first read the image into a Java Image object rather than looking at the raw image data. Is this correct?
Yes, dealing with an Image object would be easier, but I'm not familiar with it. Can you please provide some insight?

Once again, I appreciate the help very much.
 
Jon Wilson
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Micho,
I'm no expert in image processing, but hopefully I can be of assistance. The following is the way that I would proceed:
The first thing that you'll need to do is read the logo and the image that contains the logo into BufferedImage instances. If you know that the logo is roughly in the lower right corner of the image, then this can reduce processing time as we can take a sub-image that contains only the lower right corner. I am not going to show you the exact code, but you will use the BufferedImage.getSubimage(...) which returns a BufferedImage.
Starting at the upperleft pixel (0,0) of the subimage, you can use the BufferedImage.getRGB(x,y) method to grab the RGB value for that pixel. You will compare this to the RGB value of the logo's upperleft pixel. If it doesn't match, then you move to the next pixel (0,1) of the subimage and compare that to pixel (0,0) of the logo. You're basically trying to find where the first pixel of the logo is within the subimage.
If the sub-image does contain the logo, then eventually a pixel in the sub-image will match the first pixel (0,0) of the logo. Then you must compare each successive pixel in the sub-image to the respective pixel in the logo to verify that it is a complete match. This will probably be done with some sort of nested for loop.
One pitfall to watch out for...Your code may find a match between pixels (2,5) through (2,12) on the sub-image with pixels (0,0) through (0,7) on the logo. Then the next pixel may not match. Poorly written code might resume the search at pixel (2,13) of the sub-image, but you really need to resume the search at pixel (2,6) of the sub-image.
I hope this explanation makes sense; if not, I'll be glad to clarify...
Good luck!
 
Micho Lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This makes perfect sense. I was thinking that I would have to do something like this but didn't know what tools to use. Thanks for the detailed explanation. If I run across problems trying to implement something that you mentioned, I will humbly take your offer for additional help.
Best Regards.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic