pageone Posted June 29, 2006 Share Posted June 29, 2006 I am trying to convert RGB to HSL whcih is really not the problem. The problem is i need to identify the Min and Max Value of RGB ie extract the min and max from any given color. I have tried with the _Min function however my inputs for RGB are input boxes and these do not work with _Min Is there another way to extract the min and max value i dont have enough code to give you an actual example but the formulae in part is var_Min = min( var_R, var_G, var_B ) //Min. value of RGB var_Max = max( var_R, var_G, var_B ) //Max. value of RGB del_Max = var_Max - var_Min //Delta RGB value L = ( var_Max + var_Min ) / 2 any advice would be appreciated ... Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 29, 2006 Share Posted June 29, 2006 Hi, the rbg values are int between 255, right? That shouldn't be that difficult. You could also put them into an Array and use the funcs _ArrayMin _ArrayMax. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 29, 2006 Share Posted June 29, 2006 (edited) I am trying to convert RGB to HSL whcih is really not the problem. The problem is i need to identify the Min and Max Value of RGB ie extract the min and max from any given color. I have tried with the _Min function however my inputs for RGB are input boxes and these do not work with _Min Is there another way to extract the min and max value i dont have enough code to give you an actual example but the formulae in part is var_Min = min( var_R, var_G, var_B ) //Min. value of RGB var_Max = max( var_R, var_G, var_B ) //Max. value of RGB del_Max = var_Max - var_Min //Delta RGB value L = ( var_Max + var_Min ) / 2 any advice would be appreciated ... The AutoIT versions of _Min() and _Max only compare two numbers, so you would do R, G, and B seperately: Global $Red_Min = 255, $Red_Max = 0, $Green_Min = 255, $Green_Max = 0, $Blue_Min = 255, $Blue_Max = 0, $LastPixel = 0 While 1 ; Whatever code gets the individual pixel RGB values into $Pixel_RGB goes here ; $Pixel_RGB = a single pixel's 24-bit RGB value _RGB_MinMax($Pixel_RGB) ; Something sets $LastPixel = 1, or some other method to exit loop when done If $LastPixel Then ExitLoop Wend MsgBox(64, "Results", "Minimum and Maximum values for Red, Green, and Blue: " & @CRLF & _ @Tab & "Red: Min = " & $Red_Min & " Max = " & $Red_Max & @CRLF & _ @Tab & "Green: Min = " & $Green_Min & " Max = " & $Green_Max & @CRLF & _ @Tab & "Blue: Min = " & $Blue_Min & " Max = " & $Blue_Max) ; Function to test each pixel for RGB min and max values Func _RGB_MinMax($iRGB_Color) ; Seperate the input R, G, and B Local $iR = BitAnd($iRGB_Color, 0xFF0000) / 0x10000 Local $iG = BitAnd($iRGB_Color, 0xFF00) / 0x100 Local $iB = BitAnd($iRGB_Color, 0xFF) ; Test for new min and max values of each $Red_Min = _Min($Red_Min, $iR) $Red_Max = _Max($Red_Max, $iR) $Green_Min = _Min($Green_Min, $iG) $Green_Max = _Max($Green_Max, $iG) $Blue_Min = _Min($Blue_Min, $iB) $Blue_Max = _Max($Blue_Max, $iB) EndFunc Hope that helps! Edited June 29, 2006 by PsaltyDS 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...
pageone Posted June 30, 2006 Author Share Posted June 30, 2006 Thankyou for your assistance, i finally went with the array idea which worked great and taught me arrays at the same time .... $ReadRed = GUICtrlRead($Red) $ReadGreen = GUICtrlRead($Green) $ReadBlue = GUICtrlRead($Blue) Dim $avArray $avArray = _ArrayCreate($Readred, $ReadGreen, $ReadBlue) $var_min = _ArrayMin( $avArray, 1) $Var_max = _ArrayMax( $avArray, 1) $L = ($Var_Max + $Var_Min)/2 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