Image processing

  • Thread starter Thread starter ThisBytes5
  • Start date Start date
T

ThisBytes5

I have a bunch of images, some of which may have a Logo in them, not
transparent. The logo can appear anywhere in the image, usually in one
of the corners. I need to sort the images based on whether or not they
contain the logo.

I've done something like this in the past, but they were 128x128
images and I just did a pixel compare, this is SLOW. I would like to
find someway to determine if the logo is contained with in a given
image, as reliably as possible with out having to do a pixel compare.
However, I'm not even really sure where to start on this. Any help
would be appreciated.

Thanks
Wayne
 
Wow thats a great question! And I don't have an answer either.

I would think that at some stage you would need to do some sort of
pixel comparison... When the logo is in the top right position, is it
ALWAYS exactly the same distance from the top and right border? Or are
you effectively saying the logo could appear ANYWHERE and that you want
anything in the North East quadrant sorted together, NW quad together,
etc...? Is the logo always the SAME SIZE, or can it vary as well?

You could try some different algorythms to speed up the search for the
logo. Something like checking the image for the first 5 sequential
pixels of the logo, rather than the whole logo, and when you find a
match, check the remainding pixels around it for matching the rest of
the logo.

Or you could perhaps do a perimiter search. Start on the outside pixels
and work IN rather than searching from top left down to bottom right.
This might work better since your logo is always in 1 of the 4 corners.


Perhaps you could get an average color of the logo and then do a matrix
search of the document for that average color.
You could possibly maximise the speed of the search by only checking
every X pixels along for closeness to the 'average' color, and for
those that match within a certain percentage, do a more in depth check
to see if the logo exists.

Just ideas and probably filled with holes. Hope they can spark some
inspiration though.

Steven Nagy
 
How are you doing the comparison? Are you using unsafe C code to do it? That
speeds things up quite a bit.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
Currently I'm not doing the comparison, that is why I posted. I am
unsure how to do it.
 
From what I've seen so far, yes the logo is always the same size. The
logo seems to appear at the position all the time when it is in the
upper left corner it always seems to appear at 0,0. In the lower right
always appears at the same pos. Ultimately I'd like to have the
ability to find it anywhere in the image though, but finding it always
at 0,0 would be a start.


I'm going to prob write the code to do the pixel by pixel compare
just to get things started, and then modify the code as other solutions
present themselves.

Thanks
Wayne
 
Bob Powell has a great GDI+ FAQ site at:

http://www.bobpowell.net/faqmain.htm

This has all the information you need to loop through the pixels of a bitmap
with unsafe code. In particular, check out the "Using the LockBits method to
access image data" article:

http://www.bobpowell.net/lockingbits.htm

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
Back
Top