Giordano Posted February 11, 2007 Share Posted February 11, 2007 (edited) 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 February 11, 2007 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 More sharing options...
Rizzet Posted February 11, 2007 Share Posted February 11, 2007 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 More sharing options...
Bosse Posted February 11, 2007 Share Posted February 11, 2007 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 More sharing options...
Giordano Posted February 11, 2007 Author Share Posted February 11, 2007 (edited) 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 February 11, 2007 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 More sharing options...
Zedna Posted February 11, 2007 Share Posted February 11, 2007 Look at Bitmap LibraryThere is _PixelRead() for you. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Giordano Posted February 11, 2007 Author Share Posted February 11, 2007 (edited) 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 February 11, 2007 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 More sharing options...
Zedna Posted February 11, 2007 Share Posted February 11, 2007 (edited) In your For loop use:$r=0 ExitLoop 2 oÝ÷ Ú)ìµæjëh×6 $r=0 ExitLoop ExitLoopEDIT2: Tip: For "C:\1.bmp" and "C:\2.bmp" use commandline parametres Edited February 11, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Giordano Posted February 11, 2007 Author Share Posted February 11, 2007 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 [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 More sharing options...
Zedna Posted February 11, 2007 Share Posted February 11, 2007 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 Remove unneccessary ExitLoop after Return (as in my previous example) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now