|
Post by (X) on Nov 1, 2021 3:16:08 GMT 1
Hi all,
Here is demonstration program based on a compilation of pseudo code functions designed to convert color from one color space to another.
I call it a Rabbit Hole because I rapidly felt like I was getting over my head. I think I see some light at the end of the tunnel.
Enjoy!
(X)
Of course this is a work in progress, but, it can be the basis of gaining much knowledge and mastery of color space and programming in general.
Worth noting is that I found a way to clone a UDT declared in the Library and use it in the main program as if the Library had exported it!
|
|
|
Post by (X) on Nov 3, 2021 15:40:19 GMT 1
Latest versions: I worked out a bug that was not returning good RGB values from the HSL_to_RGB conversion. It was a matter of working solely with Single type variables and converting multiplications or divisions on the spot with the Csng() function.
And, yes, I did get that little rush of Dopamine when I found the problem that had been plaguing me for almost a week.
N. B.: I am modifying the code quite a bit from day to day. I will post the demo and library again, once it is more stable.
|
|
|
Post by (X) on Nov 5, 2021 12:37:38 GMT 1
Here is the User Defined Type (UDT) I created for the color space library: Lib_Color_Space.G32
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Declare a global color space user defined type (UDT) ' variable that will ultimately guide the programmer ' through the available nomenclature. ' Global CS As T_COLOR_SPACE Global Ptr_CS As Int32 = V:CS ' ' Here are the COLOR SPACE user defined types... ' Type T_COLOR_SPACE CIE As T_CS_CIE CMYK As T_CS_CMYK Hunter As T_CS_HUNTER HSL As T_CS_HSL HSV As T_CS_HSV RGB As T_CS_RGB Ref As T_CS_REF Wht As T_CS_WHT XYZ As T_CS_XYZ YXZ As T_CS_YXZ EndType Type T_CS_CIE -Single C, H, L, a, b, L1, a1, b1, L2, a2, b2, u, v EndType Type T_CS_CMYK -Single C, M, Y, K EndType Type T_CS_HUNTER -Single L, a, b EndType Type T_CS_HSL -Single H, S, L EndType Type T_CS_HSV -Single H, S, V EndType Type T_CS_REF -Single X, Y, Z, u, v EndType Type T_CS_RGB -Single R, G, B, aR, aG, aB EndType Type T_CS_WHT -Single L, C, H EndType Type T_CS_XYZ -Single X, Y, Z EndType Type T_CS_YXZ -Single X, Y, Z EndType ' ' These reference values are taken from the provided TriStimulus Table. ' With CS .Ref.X = 109.850! .Ref.Y = 100.000! .Ref.Z = 35.585! EndWith
' ' (Tristimulus) Reference values of a perfect reflecting diffuser ' ' Observer 2° (CIE 1931) 10° (CIE 1964) Note ' Illuminant X2 Y2 Z2 X10 Y10 Z10 ' A 109.850 100.000 35.585 111.144 100.000 35.200 Incandescent/tungsten ' B 99.092 100.000 85.313 99.178 100.000 84.349 Old direct sunlight at noon ' C 98.074 100.000 118.232 97.285 100.000 116.145 Old daylight ' D50 96.422 100.000 82.521 96.720 100.000 81.427 ICC profile PCS ' D55 95.682 100.000 92.149 95.799 100.000 90.926 Mid-morning daylight ' D65 95.047 100.000 108.883 94.811 100.000 107.304 Daylight, sRGB, Adobe-RGB ' D75 94.972 100.000 122.638 94.416 100.000 120.641 North sky daylight ' E 100.000 100.000 100.000 100.000 100.000 100.000 Equal energy ' F1 92.834 100.000 103.665 94.791 100.000 103.191 Daylight Fluorescent ' F2 99.187 100.000 67.395 103.280 100.000 69.026 Cool fluorescent ' F3 103.754 100.000 49.861 108.968 100.000 51.965 White Fluorescent ' F4 109.147 100.000 38.813 114.961 100.000 40.963 Warm White Fluorescent ' F5 90.872 100.000 98.723 93.369 100.000 98.636 Daylight Fluorescent ' F6 97.309 100.000 60.191 102.148 100.000 62.074 Lite White Fluorescent ' F7 95.044 100.000 108.755 95.792 100.000 107.687 Daylight fluorescent, D65 simulator ' F8 96.413 100.000 82.333 97.115 100.000 81.135 Sylvania F40, D50! simulator ' F9 100.365 100.000 67.868 102.116 100.000 67.826 Cool White Fluorescent ' F10 96.174 100.000 81.712 99.001 100.000 83.134 Ultralume 50, Philips TL85 ' F11 100.966 100.000 64.370 103.866 100.000 65.627 Ultralume 40, Philips TL84 ' F12 108.046 100.000 39.228 111.428 100.000 40.353 Ultralume 30, Philips TL83 '
|
|
|
Post by (X) on Feb 21, 2024 20:28:23 GMT 1
I worked out a few error conditions to do with the Power operator: '^'. This is the most up to date version of the library. You 'll need to compile it etc etc...
Here is a demo that converts RGB to HSL and back again to RGB.
Notice that if you change the H, S or L value in mid conversion you will get a 'modified' RGB conversion, but, if you leave HSL alone then the original RGB is restored.
|
|