Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, August 16, 2007 2:40:21 AM(UTC)

Groups: Registered
Posts: 3



I am trying to compare a set of images to each other. I would like the output to be numeric, i.e. exact match = 1 completely different = 0.


The images are grey scale images.


Is there any way this can be done using lead tools?


I do not mind if the images would require pre-processing (e.g. if the comparison is done on a pixel by pixel basis I could edit the input images to be the same size and centred around the same point)


I am using C# and leadtools 14.5.



Alistair Gilbert


Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, August 17, 2007 9:27:13 AM(UTC)


Groups: Registered, Tech Support, Administrators
Posts: 764

I'm assuming you're using the .NET interface.  Take a look at the CorrelationCommand class in the .NET help file for an example.  This function is used to look for an image inside of an image, which of course could be used to compare two entire images that are the same size.
#3 Posted : Sunday, August 19, 2007 5:51:45 AM(UTC)

Groups: Registered
Posts: 3

i have tried looking at this command. There is no way of getting the result back from the algorithm. it can only tell me if the images matched based on the threshold, i need the result (0 to 100) of how close a match they were.

is there something i am missing, can i actually get this result somehow?



#4 Posted : Monday, August 20, 2007 7:41:31 AM(UTC)


Groups: Registered, Tech Support, Administrators
Posts: 764

 ali11011 wrote:

am trying to compare a set of images to each other. I would like the output to be numeric, i.e. exact match = 1 completely different = 0.

I guess this was a typo in your previous post.  I thought that you were only wanting a binary response, which is what the CorrelationCommand could do for you.  We do not have a function that compares images and returns a percentage of how close they are.  I could submit a feature request for you if you'd like.

Otherwise, you will need to write this yourself.  It would be a difficult function to write because if it goes pixel by pixel, it would not be accurate at all, because if you had an image that only had an additional column of pixels, the entire thing would be off and would probably get a bad result even though the image was really about 99 or 98% the same.  You would probably need to have some kind of subsampling or block searching to make this accurate.

You could also try using the CorrelationCommand with chunks of the source image.  Cut your image up into 200 squares (or more or less depending on what you want to do) and then run CorrelationCommand on each square.  This would take a long time to process though, especially if you want CorrelationCommand to return accurate results.
#5 Posted : Friday, August 24, 2007 3:55:34 AM(UTC)

Groups: Registered
Posts: 3


it is proving most difficult. i am trying to process it by subtracting the images from one another then with each pixel comparing the difference in intensity and attatching a coeficient based the location of the pixel (in rlation to all other pixes) and the intensity of the comparitor pixel. This is obviously not 100% accurate.

something like:

diff = (sum{ i= 0 to H*W}((Diff_i/255 * (sum{j = 0 to Height*Width}((Diffj*Width*Height)/(255 * xDiff_Dist_j*yDiff_Dist_j)) / Hieght*Width)))/Height*Width)



#6 Posted : Monday, August 27, 2007 4:16:19 AM(UTC)


Groups: Registered, Tech Support, Administrators
Posts: 764

The difficulty with this is that similarity is a subjective term.  Some people may think that two images are very similar, but others may not.  There are so many factors such as the image being shifted in a direction, one image being larger in width and height, brightness, etc.  Two images might be exactly the same document scanned in or the exact same photograph, but mathematically it's very difficult to come up with a consistent definition of "similar".

Possibly another way to get a ballpark idea would be to subtract the entire images, then count the pixels in the resulting image that have intensities of 0, 1, 2, 3, 4, 5, etc. (probably anything above 5 is going to be negligible and not work counting).  Then you could come up with some kind of "point" system to guess how close the images are to eachother.  For example, each intensity difference is a point, so you can use AddColorToRegion (or AddColorRGBRange) and CalculateRegionArea to count the number of pixels for each color.  RGB(0,0,0) of course would get 0 points, RGB(1,1,1) would get 1 point (or 3 depending on how you want to handle color).  Just multiply the number of pixels returned from CalculateRegionArea by the point value for that color (range) and keep a running total.

The closer the total is to 0 the better match the image is. This system could work well for black and white images, but the math would be tough for color images, you'd probably need to use color ranges or else your total would get high very fast.  Once again this wouldn't be very accurate if the images were exactly the same but off by a couple pixel columns (or rows). 

I still think your best bet is to cut the image up and use CorrelationCommand.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.093 seconds.