# how do i Find a unique colour

## Recommended Posts

hey how can i find a unique colour?

i dont know how to start on this one so any help is appreciated

Hello?

##### Share on other sites

try PixelGetColor()

##### Share on other sites

try PixelGetColor()

pixelgetcolor gets the color of a pixel that is at xcoord and ycoord but

what do i do to find a unique pixel?

Hello?

##### Share on other sites

pixelgetcolor gets the color of a pixel that is at xcoord and ycoord but

what do i do to find a unique pixel?

what do you mean unique pixel.?

##### Share on other sites

Let someone punch you in the face real hard and you'll discover lots of unique colors ..... .

Agreement is not necessary - thinking for one's self is!

##### Share on other sites

Let someone punch you in the face real hard and you'll discover lots of unique colors ..... .

Can i Can i Can I?

Ontopic: you have to compare pixels, so check them all if there are more then 2 of the same color goto next

##### Share on other sites

by unique pixel i mean a pixel that will not be seen more than once

so how do i check if there are more than 1 of the same colour.

Edited by Con

Hello?

##### Share on other sites

I tried this but it took about 45 seconds just to check the first row of pixels at 1280 x 1024...

```\$test = _FindUniquePixel()
MsgBox(0,"",\$test)

Func _FindUniquePixel()
For \$Y = 0 to @DesktopHeight
For \$X = 0 to @DesktopWidth
ConsoleWrite(\$X & "," & \$Y & @CRLF)
\$result = PixelGetColor (\$X ,\$Y )
If NOT _FindMatchingPixel(\$X,\$Y,\$result) Then
Return \$result
EndIf
Next
Next
Return 0x000000
EndFunc

Func _FindMatchingPixel(\$XX,\$YY,\$color)
For \$Y = 0 to @DesktopHeight
For \$X = 0 to @DesktopWidth
\$result = PixelGetColor (\$X ,\$Y)
If \$result = \$color AND NOT (\$Y = \$YY AND \$X = \$XX) Then
Return true
EndIf
Next
Next
Return false
EndFunc```

##### Share on other sites

Here is another method. This will return the decimal value of a unique pixel if it exists, or zero if there are no unique pixels.

It is rare for only one instance of a color to appear on the screen, the only way I could get this to work was to open photoshop and use the pencil tool to draw one pixel of an extreme color, then reduce the search area to only my photoshop stage.

```;Max number of colors = 16777215

;Left,Top,Width,Height
\$test = _FindUniquePixel2(452,438,100,100)
MsgBox(0,"",\$test)

Func _FindUniquePixel2(\$LL, \$TT, \$WW, \$HH)
;Max number of colors @ 1920x1200 = 2,304,000
;Max number of colors @ 1680x1050 = 1,764,000
;Max number of colors @ 1280x1024 = 1,310,720
;Max number of colors @ 1024x768 = 786,432
;Max number of colors @ 800x600 = 480,000

;Possible colors @ 32-bit = 16,777,215
\$Max = 16777215

Local \$colorOccurences[\$Max + 1]
For \$Y = \$TT to \$TT + \$HH
For \$X = \$LL to \$LL + \$WW
\$result = PixelGetColor (\$X ,\$Y)

;Increment count of given color
\$colorOccurences[\$result] += 1
Next
Next

;Search array for pixel with only one occurence and return the color value
For \$X = 0 to \$Max
If \$colorOccurences[\$X] = 1 Then Return \$X
Next

Return 0
EndFunc```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...