Jump to content

A way to collect all the different pixel colours of a picture?


Recommended Posts

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

$File = FileOpen("test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1;Asuming the picture is 500 pixels wide and high
    For $j = 424 to 51 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

I tried running that but nothing happens. Are the coords correct? I want it to gather all the pixel colours from 59,51 to 424,459. And about the .txt file, do I need to have one already made with the name test.txt?

Edited by FadetoGrey
Link to comment
Share on other sites

  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

$File = FileOpen("test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1;Asuming the picture is 500 pixels wide and high
    For $j = 424 to 51 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

I tried running that but nothing happens. Are the coords correct? I want it to gather all the pixel colours from 59,51 to 424,459. And about the .txt file, do I need to have one already made with the name test.txt?

This should work:

$File = FileOpen("test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1;Asuming the picture is 500 pixels wide and high
    For $j = 51 to 424 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

No, it will create the file when you launch your script.

Link to comment
Share on other sites

This should work:

$File = FileOpen("test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1;Asuming the picture is 500 pixels wide and high
    For $j = 51 to 424 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

No, it will create the file when you launch your script.

Yes that worked perfectly.

Only thing is, is can it just make a list of the pixel colour vertically, because it's giving me 59,51 is 8421504 59,52 is 8421504 59,53 is 8421504 59,54 is 8421504 59,55 is 8421504 all the way across the page, then when it's at the end of the line it starts a new line. If it could put it in a big list that would work better, and also, could you make it so it doesn't say pixel number is pixel colour, just make iot state the pixel colour. Thanks.

Link to comment
Share on other sites

Yes that worked perfectly.

Only thing is, is can it just make a list of the pixel colour vertically, because it's giving me 59,51 is 8421504 59,52 is 8421504 59,53 is 8421504 59,54 is 8421504 59,55 is 8421504 all the way across the page, then when it's at the end of the line it starts a new line. If it could put it in a big list that would work better, and also, could you make it so it doesn't say pixel number is pixel colour, just make iot state the pixel colour. Thanks.

$File = FileOpen("test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1;Asuming the picture is 500 pixels wide and high
    For $j = 51 to 424 step 1;Change height and width if needed
$I_Found_This_Pixel = PixelGetColor( $i, $j )
FileWrite ( $file, $I_Found_This_Pixel & @CRLF )
Next
Next
Link to comment
Share on other sites

$File = FileOpen("test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1;Asuming the picture is 500 pixels wide and high
    For $j = 51 to 424 step 1;Change height and width if needed
$I_Found_This_Pixel = PixelGetColor( $i, $j )
FileWrite ( $file, $I_Found_This_Pixel & @CRLF )
Next
Next
Awesome, I also need it to delete any duplicates in the file, so any pixel colours that are the same it will delete, but leave one ofcourse.
Link to comment
Share on other sites

Awesome, I also need it to delete any duplicates in the file, so any pixel colours that are the same it will delete, but leave one ofcourse.

I'm not sure how to do this with the Autoit language, but I guess using Strings and/or _FileReadToArray is the way to go. You will have to wait till somebody familiar with strings checks your thread.

Link to comment
Share on other sites

I'm not sure how to do this with the Autoit language, but I guess using Strings and/or _FileReadToArray is the way to go. You will have to wait till somebody familiar with strings checks your thread.

No problem man, thanks for all your help, appreciate it. :)

Link to comment
Share on other sites

No problem man, thanks for all your help, appreciate it. :)

This should do the trick:

#Include <File.au3>
#Include <Array.au3>
Dim $A
$File = FileOpen("Test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1
    For $j = 51 to 424 step 1
$I_Found_This_Pixel = PixelGetColor( $i, $j )
FileWrite ( $file, $I_Found_This_Pixel & @CRLF )
Next
Next
Sort()
Func Sort()
_FileReadToArray(@ScriptDir & "\Test.txt", $A)
$A = _ArrayUnique($A)
_FileWriteFromArray(@ScriptDir & "\Sorted.txt", $A, 1)
EndFunc
Link to comment
Share on other sites

This should do the trick:

#Include <File.au3>
#Include <Array.au3>
Dim $A
$File = FileOpen("Test.txt", 1);Or any other name.txt
For $i = 59 to 459 step 1
    For $j = 51 to 424 step 1
$I_Found_This_Pixel = PixelGetColor( $i, $j )
FileWrite ( $file, $I_Found_This_Pixel & @CRLF )
Next
Next
Sort()
Func Sort()
_FileReadToArray(@ScriptDir & "\Test.txt", $A)
$A = _ArrayUnique($A)
_FileWriteFromArray(@ScriptDir & "\Sorted.txt", $A, 1)
EndFunc
Great thanks, but for some reason it makes the test.txt and puts all the pixels in, but then it just sits there and does nothing. Does it take some time before it's finished it's job.. or is something wrong with it?
Link to comment
Share on other sites

Great thanks, but for some reason it makes the test.txt and puts all the pixels in, but then it just sits there and does nothing. Does it take some time before it's finished it's job.. or is something wrong with it?

First of all, you need the Sorted.txt already created.

Secondly it takes some time.

I have tested it with about 30 lines of text and it worked fine.

Link to comment
Share on other sites

First of all, you need the Sorted.txt already created.

Secondly it takes some time.

I have tested it with about 30 lines of text and it worked fine.

It's still doing the same thing. I've created a blank .txt file called Sorted.txt like you said, but it just sits there and it doesn't even write one line on the Sorted.txt file.

Link to comment
Share on other sites

It's still doing the same thing. I've created a blank .txt file called Sorted.txt like you said, but it just sits there and it doesn't even write one line on the Sorted.txt file.

Try putting this:

1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
22
22
22
33
44
55
66
77
77
77
77
77
77
1
2
3
4
5
6
7
8
9

Into test.txt

Then run this

#Include <File.au3>
#Include <Array.au3>
Dim $A
Sort()
Func Sort()
_FileReadToArray(@ScriptDir & "\Test.txt", $A)
$A = _ArrayUnique($A)
_FileWriteFromArray(@ScriptDir & "\Sorted.txt", $A, 1)
EndFunc

If sorted.txt will have only unique numbers, then the script works, but your computer will take allot of time to process the colour data.

Link to comment
Share on other sites

Try putting this:

1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
22
22
22
33
44
55
66
77
77
77
77
77
77
1
2
3
4
5
6
7
8
9

Into test.txt

Then run this

#Include <File.au3>
#Include <Array.au3>
Dim $A
Sort()
Func Sort()
_FileReadToArray(@ScriptDir & "\Test.txt", $A)
$A = _ArrayUnique($A)
_FileWriteFromArray(@ScriptDir & "\Sorted.txt", $A, 1)
EndFunc

If sorted.txt will have only unique numbers, then the script works, but your computer will take allot of time to process the colour data.

Doesn't the script create test.txt? Do I make test.txt then put in those numbers? Or after I've run the script once, put it above all the pixel colours, or what?
Link to comment
Share on other sites

Doesn't the script create test.txt? Do I make test.txt then put in those numbers? Or after I've run the script once, put it above all the pixel colours, or what?

Just create a blank Test.txt in the same directory your script is. And put those numbers there.

Link to comment
Share on other sites

  • Developers

Still nothing :)

Wondering when you stop ignoring me and start doing some work with debugging/testing yourself?

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

I used the script you posted Qousio, and I get the long decimals. But now how do I translate that into an actual color? I got numbers like 16777215, which isnt hex or Decimal (that I could find with Google) the numbers seem to long. Did I mess up or is there a prerequisite before they can be used as a common hex or decimal color?

BTW Thanks for the script I've been wondering how to do this for a while. So I appreciate your work.

Chad

EDIT: was looking at another post Qousio is involved in and saw numbers very similar to mine, so off to google I go searching for a translation.

Edited by RAMMRODD
Link to comment
Share on other sites

I used the script you posted Qousio, and I get the long decimals. But now how do I translate that into an actual color? I got numbers like 16777215, which isnt hex or Decimal (that I could find with Google) the numbers seem to long. Did I mess up or is there a prerequisite before they can be used as a common hex or decimal color?

BTW Thanks for the script I've been wondering how to do this for a while. So I appreciate your work.

Chad

EDIT: was looking at another post Qousio is involved in and saw numbers very similar to mine, so off to google I go searching for a translation.

Hmm, you can convert Decimal to Hex with Hex ( expression )

Don't forget to use "0x" with hex, such as 0xNumbers when using hex.

Link to comment
Share on other sites

I used the script you posted Qousio, and I get the long decimals. But now how do I translate that into an actual color? I got numbers like 16777215, which isnt hex or Decimal (that I could find with Google) the numbers seem to long. Did I mess up or is there a prerequisite before they can be used as a common hex or decimal color?

BTW Thanks for the script I've been wondering how to do this for a while. So I appreciate your work.

Chad

EDIT: was looking at another post Qousio is involved in and saw numbers very similar to mine, so off to google I go searching for a translation.

Which code did you use? The latest one? How did you get it to work? Doesn't work for me.

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...