FadetoGrey Posted May 9, 2009 Share Posted May 9, 2009 Just wondering if there's anything you can do to collect the pixel colours of all the pixels in a picture? Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 (edited) Just wondering if there's anything you can do to collect the pixel colours of all the pixels in a picture? Theres this kool new thing, its called a loop ;;; Don't use this or your pc will explode! Look below :) This is too extreme for your PC. For $i = 0 to 16800000 Step 1; 16.8 million colours $I_Found_This_Colour = PixelSearch ( 0, 0, @desktopwidth, @DesktopHeight, 0x000000+$i );Change height and width if needed Next These should work just fine. ;Pixel Colour For $i = 0 to 500 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 500 step 1;Change height and width if needed $I_Found_This_Pixel = PixelGetColor( $i, $j ) MsgBox( 0, "", $I_Found_This_Pixel ) Next Next ;Pixel Location For $i = 0 to 500 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 500 step 1;Change height and width if needed $I_Found_This_Pixel = PixelSearch ( $i, $j, $i, $j, 0x000000, 16800000 ) MsgBox( 0, "", $I_Found_This_Pixel[0] & " " & $I_Found_This_Pixel[1] ) Next Next Edited May 9, 2009 by Qousio Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 Will it seriously explode? Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 Will it seriously explode?I don't know but doing 16.8^3 million calculations isn't really good for the processor.Just use the two codes I posted below. They should work just fine. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 None of them worked, but thanks for trying Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 None of them worked, but thanks for tryingThey both work absoloutely fine. You're doing something wrong. Its like the guy yesterday that said my script doesn't work, and he just forgot to copy the last line of the script Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 They both work absoloutely fine. You're doing something wrong. Its like the guy yesterday that said my script doesn't work, and he just forgot to copy the last line of the script 100% I copied it all right. It just gives me windows with 01 02 03 04 05 06 07 08 09 etc, surely they can't be colours can they? I thought it was a long number like 3847234. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 9, 2009 Developers Share Posted May 9, 2009 100% I copied it all right. It just gives me windows with 01 02 03 04 05 06 07 08 09 etc, surely they can't be colours can they? I thought it was a long number like 3847234.Please do yourself ( and us) a favor and do some basic training on autoit3 first before getting in these type of questions.Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 100% I copied it all right. It just gives me windows with 01 02 03 04 05 06 07 08 09 etc, surely they can't be colours can they? I thought it was a long number like 3847234. If you use the Location script it will give you pixel locations, 01, 02 ,03 are pixel locations on your screen. If you use THIS: ;Pixel Colour For $i = 0 to 500 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 500 step 1;Change height and width if needed $I_Found_This_Pixel = PixelGetColor( $i, $j ) MsgBox( 0, "", $I_Found_This_Pixel ) Next Next It will give you colour values in DECIMAL. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 If you use the Location script it will give you pixel locations, 01, 02 ,03 are pixel locations on your screen. If you use THIS: ;Pixel Colour For $i = 0 to 500 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 500 step 1;Change height and width if needed $I_Found_This_Pixel = PixelGetColor( $i, $j ) MsgBox( 0, "", $I_Found_This_Pixel ) Next Next It will give you colour values in DECIMAL. Oh yes that works great, thank you. Couple of questions, you mention 500 is both the width and height, how can I make it so it doesn't have to be one number (500), and can be two numbers (width: 100, height: 400). And also, instead of windows popping up and giving me the results, is there a way you can put the results in an open notepad file? Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 (edited) Oh yes that works great, thank you. Couple of questions, you mention 500 is both the width and height, how can I make it so it doesn't have to be one number (500), and can be two numbers (width: 100, height: 400). And also, instead of windows popping up and giving me the results, is there a way you can put the results in an open notepad file? Sure. The first FOR is the width, the second FOR is the height. So For $i = 0 to 100 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 400 step 1;Change height and width if needed Will work for (400;100) To insert the text into a notepad use FileWrite ( filehandle or "filename", "line" ) In our case $File = FileOpen("test.txt", 1);Or any other name.txt FileWrite ( $file, $i & "," & $j & " is " & $I_Found_This_Pixel ) The text will be written as X,Y is Colour. Where X,Y are the coordinates and Colour is the colour of the coordinates. The whole code looks like this: $File = FileOpen("test.txt", 1);Or any other name.txt For $i = 0 to 400 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 100 step 1;Change height and width if needed $I_Found_This_Pixel = PixelGetColor( $i, $j ) FileWrite ( $file, " " & $i & "," & $j & " is " & $I_Found_This_Pixel ) Next Next For a picture 400;100 you will get 771,500 words Edited May 9, 2009 by Qousio Link to comment Share on other sites More sharing options...
Developers Jos Posted May 9, 2009 Developers Share Posted May 9, 2009 (edited) Oh yes that works great, thank you. Couple of questions, you mention 500 is both the width and height, how can I make it so it doesn't have to be one number (500), and can be two numbers (width: 100, height: 400). And also, instead of windows popping up and giving me the results, is there a way you can put the results in an open notepad file?I am sure you gave this much thought before posting that question...Come on, did you really look at the snippet and tried understanding it before posting?Qousio is so nice to spoon feed you the answers but really ... take a moment to try and find stuff out yourself.Jos Edited May 9, 2009 by Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 Awesome stuff. Does the box in which it calculates all the pixel colour, start from the top left of the screen, and aims towards the bottom right of the screen, the same as pixel search? If that's the case then that's good Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 Awesome stuff. Does the box in which it calculates all the pixel colour, start from the top left of the screen, and aims towards the bottom right of the screen, the same as pixel search? If that's the case then that's goodI'm sorry. But what box are you talking about? Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 I'm sorry. But what box are you talking about?You know, the detection box that searches for the pixels. If you imagine a box starting at the top left, then making it's way down to the bottom right, like in PixelSearch. Is that the way it works with this code that you have put? Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 You know, the detection box that searches for the pixels. If you imagine a box starting at the top left, then making it's way down to the bottom right, like in PixelSearch. Is that the way it works with this code that you have put?You can make it search in any way, a circle, a parabola and even a cross.The search coordinates are $i and $j, you can set them to any number or function.In this case it starts searching at 0,0. And increase the Y pixel location by one after every loop. And the X pixel location by 1 after every 100 loops. So after 20 loops it will be x=0,y=20. After 120 loops it will be x=1,y=20.Etc. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 You can make it search in any way, a circle, a parabola and even a cross.The search coordinates are $i and $j, you can set them to any number or function.In this case it starts searching at 0,0. And increase the Y pixel location by one after every loop. And the X pixel location by 1 after every 100 loops. So after 20 loops it will be x=0,y=20. After 120 loops it will be x=1,y=20.Etc.Oh so you can start absolutely anywhere? So say if my desktop resolution is 800x600, if I start at 400 across, and 300 down, it would start right in the middle? Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 Oh so you can start absolutely anywhere? So say if my desktop resolution is 800x600, if I start at 400 across, and 300 down, it would start right in the middle?Yes.You can also use @Desktopwidth and @Desktopheight to get the height and width of your current resolution. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 9, 2009 Author Share Posted May 9, 2009 Run into another problem actually; The coords of the point I want the box to start from is 59,51. How would you input that into the code? $File = FileOpen("test.txt", 1);Or any other name.txt For $i = 0 to 59,51 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 424,459 step 1;Change height and width if needed $I_Found_This_Pixel = PixelGetColor( $i, $j ) FileWrite ( $file, " " & $i & "," & $j & " is " & $I_Found_This_Pixel ) Next Next Like that? Link to comment Share on other sites More sharing options...
Qousio Posted May 9, 2009 Share Posted May 9, 2009 Run into another problem actually; The coords of the point I want the box to start from is 59,51. How would you input that into the code? $File = FileOpen("test.txt", 1);Or any other name.txt For $i = 0 to 59,51 step 1;Asuming the picture is 500 pixels wide and high For $j = 0 to 424,459 step 1;Change height and width if needed $I_Found_This_Pixel = PixelGetColor( $i, $j ) FileWrite ( $file, " " & $i & "," & $j & " is " & $I_Found_This_Pixel ) Next Next Like that? No $File = FileOpen("test.txt", 1);Or any other name.txt For $i = 59 to 400 step 1;Change 400 to the end X coordinates For $j = 51 to 100 step 1;Change 100 to the end Y coordinates $I_Found_This_Pixel = PixelGetColor( $i, $j ) FileWrite ( $file, " " & $i & "," & $j & " is " & $I_Found_This_Pixel ) Next Next 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