Jump to content

Image Comparing


Giordano
 Share

Recommended Posts

hi there,

i'm italian boy and i can't speak english as well, i hope this will be not a problem!

i need to know how to make a function that check pixel color of stored images and match identical images. For example:

Func Compare($imageA, $imageB, $width, $lenght)
    For $i=0 To $width-1
        For j=0 To $lenght-1
            If getpixelcolor($imageA, $i, $j) <> getpixelcolor($imageB, $i, $j) Then
                MsgBox(0,"No Match","images are not the same")
                ExitLoop
            EndIf
        Next
    Next
    MsgBox(0,"Match","images are identical")

I'm looking for the function: getpixelcolor("c:\image.bmp","X", "Y")

can someone help me?

Edited by Giordy
[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

First of all i should tell u that im still new at this but im going to try help u a little on the way.

Func Compare($imageA, $imageB, $width, $lenght)
    For $i=0 To $width-1
        For $j=0 To $lenght-1  ;like this instead of "For j=0 To $lenght-1"
            If PixelGetColor($imageA, $i, $j) <> PixelGetColor($imageB, $i, $j) Then            ;and getpixelColor should be PixelGetColor
                MsgBox(0,"No Match","images are not the same")
                ExitLoop
            EndIf
        Next
    Next
    MsgBox(0,"Match","images are identical")

I'm looking for the function: getpixelcolor("c:\image.bmp","X", "Y")

can someone help me?

But the image thing is still wrong.. i cant help u with that..

im still totaly wrong. this script wont work

Link to comment
Share on other sites

Hi,

I think the problem is that you can 't pass a file to the PixelGetColor function. It only can return the color of a pixel which is shown on a xy-position on the screen.

Maybe you can read the files in binary and compare them.

Link to comment
Share on other sites

Hi,

I think the problem is that you can 't pass a file to the PixelGetColor function. It only can return the color of a pixel which is shown on a xy-position on the screen.

Maybe you can read the files in binary and compare them.

this is my problem! i'm looking for a function similar as PixelGetColor with image input from file, how to ask help to developers for this?

OR.. is possible to read the image (50x50) as a matrix of colors using autoit3?

OR.. how to read the binary code of a bitmap image using autoit3?

Edited by Giordy
[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

Look at Bitmap Library

There is _PixelRead() for you.

thanks for the help, this is the useful result.

i think much people can do very much things starting from this, as searching a part of image into another larger image..

#include<BMP.au3>

;~ place an image in the folder "c:\1.bmp" and make a copy of it. call it "2.bmp".
;~ Run this script, and try to modify 1 casual pixel of the image and check if are identical or different
$A=_BMPOpen("C:\1.bmp")
$B=_BMPOpen("C:\2.bmp")
$W=_BMPGetWidth($A)
$H=_BMPGetHeight($B)


$r = Compare($A,$B,$H,$W)

If $r=1 Then
    MsgBox(0,"","identical")
Else
    MsgBox(0,"","different")
EndIf

Func Compare($A,$B,$H,$W)
    $r=1
    For $i=1 To $W
        For $j=1 To $H
            If _PixelRead($A, $i, $j) <> _PixelRead($B, $i, $j) Then
                $r=0
                ExitLoop
                ExitLoop
            EndIf
        Next
    Next
    Return $r
EndFunc

YOU NEED THE Bitmap Library TO RUN THE SCRIPT

Edited by Giordy
[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

In your For loop use:

$r=0
                ExitLoop 2
oÝ÷ Ú)ìµæjëh×6                $r=0
                ExitLoop
                ExitLoop

EDIT2: Tip: For "C:\1.bmp" and "C:\2.bmp" use commandline parametres

Edited by Zedna
Link to comment
Share on other sites

thanks, i don't know as well this language yet! but i prefer so:

Func Compare($A,$B,$H,$W)
    For $i=1 To $W
        For $j=1 To $H
            If _PixelRead($A, $i, $j) <> _PixelRead($B, $i, $j) Then
                Return 0
                ExitLoop 2
            EndIf
        Next
    Next
    Return 1
EndFunc

this will not waste time in a 1280*1024 pixel image :whistle:

[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

thanks, i don't know as well this language yet! but i prefer so:

Func Compare($A,$B,$H,$W)
    For $i=1 To $W
        For $j=1 To $H
            If _PixelRead($A, $i, $j) <> _PixelRead($B, $i, $j) Then
                Return 0
                ExitLoop 2
            EndIf
        Next
    Next
    Return 1
EndFunc

this will not waste time in a 1280*1024 pixel image :whistle:

Remove unneccessary ExitLoop after Return (as in my previous example)
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...