Jump to content

Image comparison without pixelsearch


Recommended Posts

Hi everyone

I'm trying to code a simple image comparison script that can run in the background. (therefore without using pixelsearch)

The images I'm trying to compare all have the same filesize so it's not possible to compare them that way.

I also tried to "read" the images with fileread (silly but it was worth a try) and compare the raw data with every file - which didn't work.

Now I'm pretty much lost, I don't have any new ideas, pixelsearch seems to be the only way but that'd take hours plus the computer would be un-useable during this time.

I'd be grateful if you had any hints or ideas for me.

Greetings, Das

Link to comment
Share on other sites

Hi everyone

I'm trying to code a simple image comparison script that can run in the background. (therefore without using pixelsearch)

The images I'm trying to compare all have the same filesize so it's not possible to compare them that way.

I also tried to "read" the images with fileread (silly but it was worth a try) and compare the raw data with every file - which didn't work.

Now I'm pretty much lost, I don't have any new ideas, pixelsearch seems to be the only way but that'd take hours plus the computer would be un-useable during this time.

I'd be grateful if you had any hints or ideas for me.

Greetings, Das

If these pictures are exactly the same, that is, they are copies of one another, then the comparrison using FileRead() should have been sufficient. I don't understand the problem you are having.

You could use something as simple as this to see if the files are identical:

;Image Compare Test

Dim $bs_asdfJPGData = FileRead(@ScriptDir & "\asdf.JPG")

Dim $bs_asdfJPGDataCopy = FileRead(@ScriptDir & "\Copy of asdf.JPG")

If $bs_asdfJPGData == $bs_asdfJPGDataCopy Then
    MsgBox(0,"Image","The images are the same.")
;~     ConsoleWrite("The images are the same."&@LF)
Else
    MsgBox(0,"Image","The images are the different.")
;~     ConsoleWrite("The images are different."&@LF)
EndIf

;clear the file data out of memory
$bs_asdfJPGData = 0
$bs_asdfJPGDataCopy = 0

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

I'd be grateful if you had any hints or ideas for me.

Yes, what did you mean anyway, comparing two images and returning a score of comparison, or just binary-comparing them to see if they are the same or not? These would be two entirely different problems :whistle:

I've been trying to make an image comparing routine by reading raw file data and doing BitXOR operations on the read strings, or doing string comparing, or doing another bunch of stuff but I can only come up with unbelievably slow systems :P

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

You can do checksum functions, but it is not specific as to what has changed (only if anything at all changed) and if you need to compare LARGE amounts of data, it hogs CPU speed and effectively rules out anything else you would want to work on.

Now in my case this is not that big of an issue because I can dedicate a computer to it, but for me, speed is not an issue so I would like to make this be slow but forgiving to other processes, and specific as to what changed.

Only in my case I am not matching images but wave files. Same problem though.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

If these pictures are exactly the same, that is, they are copies of one another, then the comparrison using FileRead() should have been sufficient. I don't understand the problem you are having.

The problem is that they're not exact copies, they have the same filesize and resolution but the image itself is different (the pixels).

To put it simple, I'm trying OCR but I noticed a certain continuity in the images and managed to find a way to get collisions, by simply comparing the collisions I found with the other images.

Now all I have to do is make autoit compare the collision pictures I found with the other images.

Fileread doesn't seem to work for me, it crashes when I'm using it on .gif's (isn't fileread for text files only?).

The reason why I tried fileread is because if I open the .gif's in notepad I get a bunch of ascii characters which are different from file to file, I tried to use this to identify them but it didn't work.

Yes, what did you mean anyway, comparing two images and returning a score of comparison, or just binary-comparing them to see if they are the same or not? These would be two entirely different problems :whistle:

Either would be fine, I just need a way to uniquely identify those images somehow without judging by the filesize.

Edited by Das Ami
Link to comment
Share on other sites

Either would be fine, I just need a way to uniquely identify those images somehow without judging by the filesize.

Ok, done it.

$fc1 = FileRead("c:\test1.gif")
$fc2 = FileRead("c:\test2.gif")

if $fc1 = $fc2 Then
    MsgBox(0,"test","files match ")

Else
    MsgBox(0,"test","files do not match")
EndIf

FileWrite("c:\test3.gif",$fc1)

Now take a small c:\test1.gif, copy it to c:\test2.gif, and you run this code. It will say they match. On top of that, the FileWrite will write the exact gif back into test3.gif and it is an exact copy. Now change a pixel in test2.gif, and they will NOT match. That works. (But when you show for instance $fc1 in a msgbox it will only show like 6 characters... But never mind that. :whistle:)

Seems to all work.

ORRRRRRRRR: you could just use the DOS 'fc' command and catch the output, that is very easy too :P

BTW yes, the help states that fileread is for text files, I always thought it was too, but it seems able to handle these gifs just as well :D

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...