Jump to content

image comparison


Recommended Posts


I am new to Autoit i have a problem in comparing the two screenshos

one original and another is taken sceenshot of emulator ...i have attached the screen shots to compare and find the differance in image........

Please help me to make it automate the image comparison...........


Link to comment
Share on other sites

  • Moderators


Wrong part of the forum, no attachments to be seen, and asking for someone to write code for you. Pretty poor post! :graduated:


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to comment
Share on other sites

Thanks for reply, actuly i am using the code

$image1 = FileRead("C:\image\scree2.bmp")

$image2 = FileRead("C:\image\scree3.bmp")

If $image1==$image2 Then

MsgBox(0,"test","files match ")


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


but i want to ignore the some portion in the image while comparing...

is it possible?

Link to comment
Share on other sites

Now i using $image1 = FileRead("C:\image\scree2.bmp")

$image2 = FileRead("C:\image\scree3.bmp")

If $image1==$image2 method to compare the images ... is it posible to compare the dowm portion and top portion of the image .....

2)And i have one more quetion i have used ....Func FileListToArray($Dir , $Dir2)

Dim $FilePath,$FilesList,$Files,$i

Dim $FilePath2,$FilesList2,$Files2,$j



If (Not IsArray($FilesList)) and (@Error=1) Then

MsgBox (0,"","No Files\Folders Found.")





If IsArray($Files ) Then

For $i=1 To $Files[0]

for $j=1 To $Files2[0]



If $FilePath==$FilePath2 Then






to get the image files from the directory ... But its no working properly,, Please check it what is the wrong?....Help is appreciated.

Link to comment
Share on other sites

If you want to check binary content, you'll be better off using something like that:

Func CompareFilesBinaryContent($file1, $file2)
$resTxt = ""
$handle = FileOpen(FileGetShortNameV2($file1), 16)
$content1 = FileRead($handle)
$handle = FileOpen(FileGetShortNameV2($file2), 16)
$content2 = FileRead($handle)
$str_diff = StringCompareExV1($content1, $content2)
If $str_diff Then
$resTxt = "Files have different binary content."
$resTxt &= @CRLF & "File1='" & $file1 & "'"
$resTxt &= @CRLF & "File2='" & $file2 & "'"
Return $resTxt
EndFunc   ;==>CompareFilesBinaryContent

As for isolating part of image that are similar from the ones that are different, this is difficult problem. A lot of people are working on it ( inclusing in people in Universities - pattern recognition, image similarities, etc. ), but I haven't stumbled on an easy to use/implement solution yet. Academia is on it. Developers are on it ( eg. http://www.codeproject.com/KB/GDI-plus/comparingimages.aspx ). Let us know if you have more luck.

On a more personal note, I started writing a C# application a couple years ago that would group pixels and and search for similarities but interrupted this project because I found an easier way to achieve what I needed: 1/ I compare bare binary content and then 2/ I swap the 2 images every second at the same place and I visually check for differences (works great even for very tiny differences).

Take care.

-- Edited Tuesday, 4 October 2011, 6:23 PM

Note here is another similar work: if you can search for a pixel on the screen, then you can search for a given pixel in another image. The problems are somehow related.

Edited by Chess
Link to comment
Share on other sites

  • 2 weeks later...

If you need to check if an image is the same, why not render the image on a GUI and use PixelChecksum to calculate a checksum of a pre-defined area? If the images are the same size and the part on the image to check is in the same place, then doing this method will give you a clear yes or no to if its different. Even if the location is different you may be able to intuit the location to search using PixelSearch and PixelGetColor to define the coordinates of an area that could be quantified each time yet may be in a different location on the screen perhaps.

Link to comment
Share on other sites

I am finding the apllication in the list by copying the text and comparing that text to the given application name

;copying the application name

$data= ClipGet()

Local $file=FileOpen($Appname, 1)


_FileReadToArray($file, $fdata)

$CountLines = _FileCountLines($file)

For $x = 1 to $CountLines Step 1

$sourcePath = $fdata[$x]


If StringRegExp ($sourcePath, "AnimationApp", 0) == 1 Then

MsgBox(0, "yes", "i am")


problem is to run the scripts one by one ...after finding the application....

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

Hi All,

I have some problem in this code

to compare the 2 directory images plz see bellow script....

Func ImgComp2()

Global $file1=_FileListToArray("C:Sdk_AutomationDatabaseWQVGA" & $mytext2 & "", "*.bmp", 1)

Global $file2=_FileListToArray("C:Sdk_AutomationOutputImagesWQVGA"& $mytext2 & "","*.bmp",1)

For $i=1 To UBound($file1)-1



;MsgBox(0, "", $file1[$i])

;MsgBox(0, "", $file2[$i])

If $ram1==$ram2 Then


;MsgBox(0, "", "ok")



;MsgBox(0, "", "NG")



I am comparing 2 directory images one for updating the outputs but its not working properly plz check it once help should be apreciated...

Thanks in advance

Edited by Mallikarjun
Link to comment
Share on other sites

Its comparing the images when i comparing the single images.



If $ram1==$ram2 Then

MsgBox(0, "", "good luck")


MsgBox(0, "", "no")


but the problem occurs to compare the multiple images.

help should be appreciated


Edited by Mallikarjun
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

  • Recently Browsing   0 members

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