Re: comparing images...
From: Ed Astle (ed.REMOVE_IT.astle_at_thomson.com)
Date: 03/15/04
- Next message: cody: "Re: Graphics.ScaleTransform vs. Graphics.Transform.Scale"
- Previous message: Andrew S \(Infragistics\): "Re: Graphics.ScaleTransform vs. Graphics.Transform.Scale"
- In reply to: David: "comparing images..."
- Next in thread: Tom Wells: "Re: comparing images..."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 15 Mar 2004 12:49:30 -0000
"David" <david@rrtt.net> wrote in message
news:%23%23qACQfCEHA.684@tk2msftngp13.phx.gbl...
> Hello...
> i've two, 100% identical images in two fales, in fact the only thing what
> differs is their name...
> i've loaded them to two diffrent pictureboxes (C#)...
> is there a way of compering between those two pictureboxes "Image"
property,
> if the picture is same? or any other way to "compare" it, even with the
70%
> of accuracy???
>
Simply subtract one image from the other and you could use the sum of the
differences as a kind of "difference factor".
You could either find the differences between each colour channel or just
take the grayscale view of things, which is simpler.
Assuming you have 2 same sized RGB images the try something like
sum_of_differences = 0
master_sum = 0
for each y // Intensity difference...
for each x
RGB master_pixel = master_image[x,y]
RGB image_pixel = image[x,y]
int master_intensity = master_pixel.R + master_pixel.G +
master_pixel.B // Add R+G+B
int image_intensity = image_pixel.R + image_pixel.G + image_pixel.B
// Add R+G+B
int intensity_difference = master_intensity - image_intensity
// Find difference
sum_of_differences = sum_of_differences + abs(
intensity_difference )
master_sum = master_sum + master_intensity
When the code finishes then you possibly (because I haven't even tried this)
have "master_sum" and "sum_of_differences".
As a % it would be 100 * (sum_of_differences / master_sum).
If the images were identical then sum_of_differences = 0, so you get 0%
difference. If "image" was pure black then sum_of_differences should be the
same as master_sum, so you get 100% difference.
It's not much extra work to find the differences of the RGB colour channels
individually - it depends how accurate you want your estimate to be.
Like I said - I haven't tried it but that's how I'd attempt it.
Or just XOR the two images. If they're the same you'll end up with nothing
(all black). There's probably a bitblt type of thing for doing this quickly.
Regards,
Ed
- Next message: cody: "Re: Graphics.ScaleTransform vs. Graphics.Transform.Scale"
- Previous message: Andrew S \(Infragistics\): "Re: Graphics.ScaleTransform vs. Graphics.Transform.Scale"
- In reply to: David: "comparing images..."
- Next in thread: Tom Wells: "Re: comparing images..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|