joeyone Posted February 5, 2008 Share Posted February 5, 2008 (edited) imagine we have a color that is blue and somtimes this color changes to slightly darker blue or lighter blue even if it changes we need to identify the color as "blue" i need to find this information at a specific pixel using pixelgetcolor (or any other function if there is a better way to do this). i also want to know how to put the information in a loop so i can search for more than one color how do i do this? hope someone can help me with this thanks Edited February 5, 2008 by joeyone Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 5, 2008 Share Posted February 5, 2008 imagine we have a color that is blue and somtimes this color changes to slightly darker blue or lighter blue even if it changes we need to identify the color as "blue"i need to find this information at a specific pixel using pixelgetcolor (or any other function if there is a better way to do this).i also want to know how to put the information in a loop so i can search for more than one colorhow do i do this?hope someone can help me with this thanksNot a problem. First step: define "Blue".Give us your mathematical definition of "Blue", in the context of a 24bit RGB color.Once you have that, the code is easy. Of course, that definition IS the hard part... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
joeyone Posted February 5, 2008 Author Share Posted February 5, 2008 Not a problem. First step: define "Blue".Give us your mathematical definition of "Blue", in the context of a 24bit RGB color.Once you have that, the code is easy. Of course, that definition IS the hard part... i mean just small changesfor example R 100 - 103G 204 - 214B 47 - 50so if we know between witch ranges the color is shown how do we do then? Link to comment Share on other sites More sharing options...
weaponx Posted February 5, 2008 Share Posted February 5, 2008 I posted a script to convert RGB color to HSB, with this you can determine the threshold of what you think is "blue", and use a condition to only accept Hues within a certain number of degrees of absolute blue.http://www.autoitscript.com/forum/index.php?showtopic=63674For example:$result = _RGBtoHSB(000, 000, 255)MsgBox(0, "Blue", "H:" & $result[0] & @CRLF & "S:" & $result[1] & @CRLF & "B:" & $result[2]);If hue is near 240 degrees, saturation and brightness are greater than 37%If ($result[0] >= 220 $result[0] <= 250) AND ($result[1] > 37) AND ($result[2] > 37) Then... Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 5, 2008 Share Posted February 5, 2008 i mean just small changes for example R 100 - 103 G 204 - 214 B 47 - 50 so if we know between witch ranges the color is shown how do we do then? If you want to get the component values from the RGB value: HotKeySet("{ESC}", "_Quit") While 1 $avMousePos = MouseGetPos() $avColor = _PixelGetColorValues($avMousePos[0], $avMousePos[1]) ToolTip("Pixel Color at: x=" & $avMousePos[0] & " y=" & $avMousePos[1] & @LF & _ "Color = 0x" & Hex($avColor[0], 6) & " (" & $avColor[0] & ")" & @LF & _ "Red = 0x" & Hex($avColor[1], 2) & " (" & $avColor[1] & ")" & @LF & _ "Green = 0x" & Hex($avColor[2], 2) & " (" & $avColor[2] & ")" & @LF & _ "Blue = 0x" & Hex($avColor[3], 2) & " (" & $avColor[3] & ")") WEnd ; Returns the color values of a pixel in an array: ; [0] = RGB integer value ; [1] = Red byte ; [2] = Green byte ; [3] = Blue byte Func _PixelGetColorValues($x, $y) Local $iColor = Number(PixelGetColor($x, $y)) Local $avRGB[4] = [$iColor, (BitAND($iColor, 0xFF0000) / 16^4), (BitAND($iColor, 0x00FF00) / 16^2), BitAND($iColor, 0x0000FF)] Return $avRGB EndFunc Func _Quit() Exit EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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