 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Larry Guest
|
Posted: Mon Jan 19, 2004 8:12 am Post subject: Finding similar images |
|
|
Can anyone tell me how, or point me in the right direction, to find
duplicate image files as well as closely similar images? I want to
programmatically "look" at 2 or more images and figure out if they are the
same image, though one may have been resized or have had a border added or
something. I have no clue how to even start doing this. Thanks!
|
|
| Back to top |
|
 |
Larry Guest
|
Posted: Thu Jan 22, 2004 4:51 am Post subject: Re: Finding similar images |
|
|
| Quote: | Can anyone tell me how, or point me in the right direction, to find
duplicate image files as well as closely similar images? I want to
programmatically "look" at 2 or more images and figure out if they
are the same image, though one may have been resized or have had a
border added or something. I have no clue how to even start doing
this. Thanks!
The problem is, as allways: What is your strict definition of "similarity"
?
Once you can answer this, you should be able to either write the code. Or,
ask specific questions on how to do it, or...conclude that it for some
reason can't be done whith that specific definition
|
My definition of similarity is that the 2 images being compared started out
as the same image. Somewhere along the way, brightness, gamma, contrast,
color balance, etc. may have been adjusted, a border or some text may have
been added, perhaps even some cropping has occurred, but visually a person
would be able to tell they are the same image. I know there is software out
there that will do this sort of similarity testing very accurately, I was
hoping there was some standard and well-known method of doing this sort of
thing...
| Quote: | A few examples:
Two pictures are concidered 'similar' when:
- height/width ratios are equal (if you don't assume this, you need to be
really advcanced)
- divided into equal numbers of squares, the average brightness values of
these squares (RGB combined) sort to the same order
|
I can see where this might work, have to try it... To compensate for color,
gamma, brightness, etc being adjusted, perhaps you could compare the average
variance between averaged values for the squares instead?
| Quote: | A "border" is present if there is a "line" at the outer edges of the image
made up of 1 color only.
- Starting from the outer pixel, move inwards until color changes
- Then, check if the entire image edge has the same color.
(the borders may be of somewhat different widths, and you need to handle
the
corners, where borders meet)
Do the border test first, compare images afterwards (taking image borders
into account).
|
Border detection makes perfect sense and should be a simple enough exercise.
| Quote: | --
Regards,
Bjørge Sæther
[email]bjorge (AT) haha_itte (DOT) no[/email]
|
Thanks!
Larry
|
|
| Back to top |
|
 |
Bob Richardson Guest
|
Posted: Thu Jan 22, 2004 6:21 pm Post subject: Re: Finding similar images |
|
|
| Quote: | A "border" is present if there is a "line" at the outer edges of the
image
made up of 1 color only.
- Starting from the outer pixel, move inwards until color changes
- Then, check if the entire image edge has the same color.
(the borders may be of somewhat different widths, and you need to handle
the
corners, where borders meet)
Do the border test first, compare images afterwards (taking image
borders
into account).
Border detection makes perfect sense and should be a simple enough
exercise. |
On some of my digital photos, I really like to put "wooden" frames. There
are free downloads that can be used with PhotoShop which allow you to choose
among 20 or more different wood types (pine, oak, etc.), and of course there
are different styles. Thus, the test for a border is much more difficult,
since a "solid" color isn't involved...the digital wood has a nice grain
look.
Concerning height/width ratios, one of the most obvious fixes to a photo is
to crop it, which change the ratio almost every time.
You also have to consider that two photos might be identical/similar, but
just rotated 90 or 180 degrees, and certainly a grayscale conversion of a
colored pic would be "similar," or perhaps one pic slightly darkened, or
flash-filled.
If you've played with PhotoShop or any graphics program, you know that a
photo can be manipulated in a bazillion different ways.
Given all that, here's my first attempt at a process:
1. convert both pics to grayscale
2. find several, non-contiguous, major transition points in each photo.
3. if most angles between these transition points are equal, I would next
try to superimpose one picture on the other, shrinking the larger photo if
necessary. Consider ALL possible rotations-not just 90,180,270 degrees. (I
take many photos with the sea as a backdrop - and I often rotate my pics 1
or 2 degrees to level out the horizon).
4.At this point, any frame would be "hanging out" - and thus you would lop
it off. (If both pics had frames, just the larger frame would have some of
it trimmed away).
5. Remove any remaining, frame-like, border (so it won't skew your
brightness normalizing)
6. I would probably shrink both photos to a fairly small size (100 X 100 or
smaller) to make sure I'm looking at the forest, not the trees.
7. Next normalize both pics to the same brightness and contrast scale.
8. Then do a pixel by pixel comparison, testing the change in darkness
rather than the absolute level of darkness. Go left-right, up-down, and on a
diagonal.
In other words, my approach would be to dumb down both pictures so that only
the essence remains, then compare. Reducing the pics to 100 X 100 black and
whites will make the task manageable.
The hardest part will be defining transition points - from light to dark,
while not getting confused by additions to the photo. For example, two Mona
Lisa's, but one has a black tape over her lips. There will be several
"transition points" created by the tape in one pic, but not the other.
Another "fraud" might be Mona Lisa in a snow storm, or behind a chain linked
fence.
It would nice (for testing and debugging purposes) if your initial program
(while you're developing your algorithms) showed the two pics, side by side,
as the photos gradually got rotated, sized, and trimmed.
|
|
| Back to top |
|
 |
Martin Harvey (Demon Acco Guest
|
Posted: Thu Jan 22, 2004 11:17 pm Post subject: Re: Finding similar images |
|
|
On Thu, 22 Jan 2004 10:21:28 -0800, "Bob Richardson"
<bobr (AT) whidbey (DOT) com> wrote:
| Quote: | Given all that, here's my first attempt at a process:
|
If you want a far more general and effective method for determining
image similarity, have a loook at gabor transforms :-)
MH.
|
|
| Back to top |
|
 |
Larry Guest
|
Posted: Sun Jan 25, 2004 4:31 am Post subject: Re: Finding similar images |
|
|
Been checking out some info online regarding Gabor transformations... not
exactly light reading...
"Martin Harvey (Demon Account)" <martin (AT) _nospam_pergolesi (DOT) demon.co.uk> wrote
in message news:hfm0109bgkhnqq309kmtl24hlt3foeu1qg (AT) 4ax (DOT) com...
| Quote: | On Thu, 22 Jan 2004 10:21:28 -0800, "Bob Richardson"
[email]bobr (AT) whidbey (DOT) com[/email]> wrote:
Given all that, here's my first attempt at a process:
If you want a far more general and effective method for determining
image similarity, have a loook at gabor transforms :-)
MH.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|