News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Find White reference for tristimulus in XYZ Colorspace

Started by guga, January 23, 2019, 05:32:47 AM

Previous topic - Next topic

guga

Hi Guys, i made a small function to retrieve the correct values of the Tristimulus (White reference or White space)  data on the XYZ Colorspace. In order to maintain the currently convention, i used the same notaton names as in CIE, rather then the full "talking name" (which i prefer, btw). So, the equates used to represent Incandescent light are "WS_A_OBS2" or "WS_A_OBS10" etc....Again..personally, i would changed them to WS_TUNGSTEN_OBS2 OR  WS_TUNGSTEN_OBS10, but i tried to keep the naming convention untouched.



[WHITE_SPACE_A_X_OBS2: R$ 109.850       WHITE_SPACE_A_Y_OBS2: R$ 100        WHITE_SPACE_A_Z_OBS2: R$ 35.585     ; Incandescent/tungsten
WHITE_SPACE_A_X_OBS10: R$ 111.144      WHITE_SPACE_A_Y_OBS10: R$ 100       WHITE_SPACE_A_Z_OBS10: R$ 35.200    ; Incandescent/tungsten

WHITE_SPACE_B_X_OBS2: R$ 99.0927       WHITE_SPACE_B_Y_OBS2: R$ 100        WHITE_SPACE_B_Z_OBS2: R$ 85.313     ; Old direct sunlight at noon
WHITE_SPACE_B_X_OBS10: R$ 99.178       WHITE_SPACE_B_Y_OBS10: R$ 100       WHITE_SPACE_B_Z_OBS10: R$ 84.3493   ; Old direct sunlight at noon

WHITE_SPACE_C_X_OBS2: R$ 98.074        WHITE_SPACE_C_Y_OBS2: R$ 100        WHITE_SPACE_C_Z_OBS2: R$ 118.232    ; Old daylight
WHITE_SPACE_C_X_OBS10: R$ 97.285       WHITE_SPACE_C_Y_OBS10: R$ 100       WHITE_SPACE_C_Z_OBS10: R$ 116.145   ; Old daylight

WHITE_SPACE_D50_X_OBS2: R$ 96.422      WHITE_SPACE_D50_Y_OBS2: R$ 100      WHITE_SPACE_D50_Z_OBS2: R$ 82.521   ; ICC profile PCS
WHITE_SPACE_D50_X_OBS10: R$ 96.720     WHITE_SPACE_D50_Y_OBS10: R$ 100     WHITE_SPACE_D50_Z_OBS10: R$ 81.427  ; ICC profile PCS

WHITE_SPACE_D55_X_OBS2: R$ 95.682      WHITE_SPACE_D55_Y_OBS2: R$ 100      WHITE_SPACE_D55_Z_OBS2: R$ 92.149   ; Mid-morning daylight
WHITE_SPACE_D55_X_OBS10: R$ 95.799     WHITE_SPACE_D55_Y_OBS10: R$ 100     WHITE_SPACE_D55_Z_OBS10: R$ 90.926  ; Mid-morning daylight

WHITE_SPACE_D65_X_OBS2: R$ 95.047      WHITE_SPACE_D65_Y_OBS2: R$ 100      WHITE_SPACE_D65_Z_OBS2: R$ 108.883  ; Daylight, sRGB, Adobe-RGB
WHITE_SPACE_D65_X_OBS10: R$ 94.811     WHITE_SPACE_D65_Y_OBS10: R$ 100     WHITE_SPACE_D65_Z_OBS10: R$ 107.304 ; Daylight, sRGB, Adobe-RGB

WHITE_SPACE_D75_X_OBS2: R$ 94.972      WHITE_SPACE_D75_Y_OBS2: R$ 100      WHITE_SPACE_D75_Z_OBS2: R$ 122.638  ; North sky daylight
WHITE_SPACE_D75_X_OBS10: R$ 94.416     WHITE_SPACE_D75_Y_OBS10: R$ 100     WHITE_SPACE_D75_Z_OBS10: R$ 120.641 ; North sky daylight

WHITE_SPACE_E_X_OBS2: R$ 100           WHITE_SPACE_E_Y_OBS2: R$ 100        WHITE_SPACE_E_Z_OBS2: R$ 100        ; Equal energy
WHITE_SPACE_E_X_OBS10: R$ 100          WHITE_SPACE_E_Y_OBS10: R$ 100       WHITE_SPACE_E_Z_OBS10: R$ 100       ; Equal energy

WHITE_SPACE_F1_X_OBS2: R$ 92.834       WHITE_SPACE_F1_Y_OBS2: R$ 100       WHITE_SPACE_F1_Z_OBS2: R$ 103.665   ; Daylight Fluorescent
WHITE_SPACE_F1_X_OBS10: R$ 94.791      WHITE_SPACE_F1_Y_OBS10: R$ 100      WHITE_SPACE_F1_Z_OBS10: R$ 103.191  ; Daylight Fluorescent

WHITE_SPACE_F2_X_OBS2: R$ 99.187       WHITE_SPACE_F2_Y_OBS2: R$ 100       WHITE_SPACE_F2_Z_OBS2: R$ 67.395    ; Cool fluorescent
WHITE_SPACE_F2_X_OBS10: R$ 103.280     WHITE_SPACE_F2_Y_OBS10: R$ 100      WHITE_SPACE_F2_Z_OBS10: R$ 69.026   ; Cool fluorescent

WHITE_SPACE_F3_X_OBS2: R$ 103.754      WHITE_SPACE_F3_Y_OBS2: R$ 100       WHITE_SPACE_F3_Z_OBS2: R$ 49.861    ; White Fluorescent
WHITE_SPACE_F3_X_OBS10: R$ 108.968     WHITE_SPACE_F3_Y_OBS10: R$ 100      WHITE_SPACE_F3_Z_OBS10: R$ 51.965   ; White Fluorescent

WHITE_SPACE_F4_X_OBS2: R$ 109.147      WHITE_SPACE_F4_Y_OBS2: R$ 100       WHITE_SPACE_F4_Z_OBS2: R$ 38.813    ; Warm White Fluorescent
WHITE_SPACE_F4_X_OBS10: R$ 114.961     WHITE_SPACE_F4_Y_OBS10: R$ 100      WHITE_SPACE_F4_Z_OBS10: R$ 40.963   ; Warm White Fluorescent

WHITE_SPACE_F5_X_OBS2: R$ 90.872       WHITE_SPACE_F5_Y_OBS2: R$ 100       WHITE_SPACE_F5_Z_OBS2: R$ 98.723    ; Daylight Fluorescent
WHITE_SPACE_F5_X_OBS10: R$ 93.369      WHITE_SPACE_F5_Y_OBS10: R$ 100      WHITE_SPACE_F5_Z_OBS10: R$ 98.636   ; Daylight Fluorescent

WHITE_SPACE_F6_X_OBS2: R$ 97.309       WHITE_SPACE_F6_Y_OBS2: R$ 100       WHITE_SPACE_F6_Z_OBS2: R$ 60.191    ; Lite White Fluorescent
WHITE_SPACE_F6_X_OBS10: R$ 102.148     WHITE_SPACE_F6_Y_OBS10: R$ 100      WHITE_SPACE_F6_Z_OBS10: R$ 62.074   ; Lite White Fluorescent

WHITE_SPACE_F7_X_OBS2: R$ 95.044       WHITE_SPACE_F7_Y_OBS2: R$ 100       WHITE_SPACE_F7_Z_OBS2: R$ 108.755   ; Daylight fluorescent, D65 simulator
WHITE_SPACE_F7_X_OBS10: R$ 95.792      WHITE_SPACE_F7_Y_OBS10: R$ 100      WHITE_SPACE_F7_Z_OBS10: R$ 107.687  ; Daylight fluorescent, D65 simulator

WHITE_SPACE_F8_X_OBS2: R$ 96.413       WHITE_SPACE_F8_Y_OBS2: R$ 100       WHITE_SPACE_F8_Z_OBS2: R$ 82.333    ; Sylvania F40, D50 simulator
WHITE_SPACE_F8_X_OBS10: R$ 97.115      WHITE_SPACE_F8_Y_OBS10: R$ 100      WHITE_SPACE_F8_Z_OBS10: R$ 81.135   ; Sylvania F40, D50 simulator

WHITE_SPACE_F9_X_OBS2: R$ 100.365      WHITE_SPACE_F9_Y_OBS2: R$ 100       WHITE_SPACE_F9_Z_OBS2: R$ 67.868    ; Cool White Fluorescent
WHITE_SPACE_F9_X_OBS10: R$ 102.116     WHITE_SPACE_F9_Y_OBS10: R$ 100      WHITE_SPACE_F9_Z_OBS10: R$ 67.826   ; Cool White Fluorescent

WHITE_SPACE_F10_X_OBS2: R$ 96.174      WHITE_SPACE_F10_Y_OBS2: R$ 100      WHITE_SPACE_F10_Z_OBS2: R$ 81.712   ; Ultralume 50, Philips TL85
WHITE_SPACE_F10_X_OBS10: R$ 99.001     WHITE_SPACE_F10_Y_OBS10: R$ 100     WHITE_SPACE_F10_Z_OBS10: R$ 83.134  ; Ultralume 50, Philips TL85

WHITE_SPACE_F11_X_OBS2: R$ 100.966     WHITE_SPACE_F11_Y_OBS2: R$ 100      WHITE_SPACE_F11_Z_OBS2: R$ 64.370   ; Ultralume 40, Philips TL84
WHITE_SPACE_F11_X_OBS10: R$ 103.866    WHITE_SPACE_F11_Y_OBS10: R$ 100     WHITE_SPACE_F11_Z_OBS10: R$ 65.627  ; Ultralume 40, Philips TL84

WHITE_SPACE_F12_X_OBS2: R$ 108.046     WHITE_SPACE_F12_Y_OBS2: R$ 100      WHITE_SPACE_F12_Z_OBS2: R$ 39.228   ; Ultralume 30, Philips TL83
WHITE_SPACE_F12_X_OBS10: R$ 111.428    WHITE_SPACE_F12_Y_OBS10: R$ 100     WHITE_SPACE_F12_Z_OBS10: R$ 40.353] ; Ultralume 30, Philips TL83

[WhiteSpaceXDis 0
WhiteSpaceYDis 8
WhiteSpaceZDis 16]

[Size_Of_WhiteSpace 24]

[WS_A_OBS2 0
WS_A_OBS10 1
WS_B_OBS2 2
WS_B_OBS10 3
WS_C_OBS2 4
WS_C_OBS10 5
WS_D50_OBS2 6
WS_D50_OBS10 7
WS_D55_OBS2 8
WS_D55_OBS10 9
WS_D65_OBS2 10
WS_D65_OBS10 11
WS_D75_OBS2 12
WS_D75_OBS10 13
WS_E_OBS2 14
WS_E_OBS10 15
WS_F1_OBS2 16
WS_F1_OBS10 17
WS_F2_OBS2 18
WS_F2_OBS10 19
WS_F3_OBS2 20
WS_F3_OBS10 21
WS_F4_OBS2 22
WS_F4_OBS10 23
WS_F5_OBS2 24
WS_F5_OBS10 25
WS_F6_OBS2 26
WS_F6_OBS10 27
WS_F7_OBS2 28
WS_F7_OBS10 29
WS_F8_OBS2 30
WS_F8_OBS10 31
WS_F9_OBS2 32
WS_F9_OBS10 33
WS_F10_OBS2 34
WS_F10_OBS10 35
WS_F11_OBS2 36
WS_F11_OBS10 37
WS_F12_OBS2 38
WS_F12_OBS10 39]


;;
    This function finds the correct White Reference (Tristimulus) values for usage in XYZ colorspace

    Parameters:
       
        pRefX - A pointer to a buffer that will be stored the value of X White Reference. The size of the buffer must be in Real8 format. So, 8 bytes to hold the double FPU data.
       
        pRefY - A pointer to a buffer that will be stored the value of Y White Reference. The size of the buffer must be in Real8 format. So, 8 bytes to hold the double FPU data.
       
        pRefZ - A pointer to a buffer that will be stored the value of Z White Reference. The size of the buffer must be in Real8 format. So, 8 bytes to hold the double FPU data.
       
        Flag -  A integer value to retrieve the proper data. The flag can be any of the following equates:

                Equate Name     Value    Observer       Description
                ___________________________________________________________________________________________________
                WS_A_OBS2       0        2°(CIE 1931)   ; Incandescent/tungsten
                WS_A_OBS10      1        10°(CIE 1964)  ; Incandescent/tungsten
                WS_B_OBS2       2        2°(CIE 1931)   ; Old direct sunlight at noon
                WS_B_OBS10      3        10°(CIE 1964)  ; Old direct sunlight at noon
                WS_C_OBS2       4        2°(CIE 1931)   ; Old daylight
                WS_C_OBS10      5        10°(CIE 1964)  ; Old daylight
                WS_D50_OBS2     6        2°(CIE 1931)   ; ICC profile PCS
                WS_D50_OBS10    7        10°(CIE 1964)  ; ICC profile PCS
                WS_D55_OBS2     8        2°(CIE 1931)   ; Mid-morning daylight
                WS_D55_OBS10    9        10°(CIE 1964)  ; Mid-morning daylight
                WS_D65_OBS2     10       2°(CIE 1931)   ; Daylight, sRGB, Adobe-RGB
                WS_D65_OBS10    11       10°(CIE 1964)  ; Daylight, sRGB, Adobe-RGB
                WS_D75_OBS2     12       2°(CIE 1931)   ; North sky daylight
                WS_D75_OBS10    13       10°(CIE 1964)  ; North sky daylight
                WS_E_OBS2       14       2°(CIE 1931)   ; Equal energy
                WS_E_OBS10      15       10°(CIE 1964)  ; Equal energy
                WS_F1_OBS2      16       2°(CIE 1931)   ; Daylight Fluorescent
                WS_F1_OBS10     17       10°(CIE 1964)  ; Daylight Fluorescent
                WS_F2_OBS2      18       2°(CIE 1931)   ; Cool fluorescent
                WS_F2_OBS10     19       10°(CIE 1964)  ; Cool fluorescent
                WS_F3_OBS2      20       2°(CIE 1931)   ; White Fluorescent
                WS_F3_OBS10     21       10°(CIE 1964)  ; White Fluorescent
                WS_F4_OBS2      22       2°(CIE 1931)   ; Warm White Fluorescent
                WS_F4_OBS10     23       10°(CIE 1964)  ; Warm White Fluorescent
                WS_F5_OBS2      24       2°(CIE 1931)   ; Daylight Fluorescent
                WS_F5_OBS10     25       10°(CIE 1964)  ; Daylight Fluorescent
                WS_F6_OBS2      26       2°(CIE 1931)   ; Lite White Fluorescent
                WS_F6_OBS10     27       10°(CIE 1964)  ; Lite White Fluorescent
                WS_F7_OBS2      28       2°(CIE 1931)   ; Daylight fluorescent, D65 simulator
                WS_F7_OBS10     29       10°(CIE 1964)  ; Daylight fluorescent, D65 simulator
                WS_F8_OBS2      30       2°(CIE 1931)   ; Sylvania F40, D50 simulator
                WS_F8_OBS10     31       10°(CIE 1964)  ; Sylvania F40, D50 simulator
                WS_F9_OBS2      32       2°(CIE 1931)   ; Cool White Fluorescent
                WS_F9_OBS10     33       10°(CIE 1964)  ; Cool White Fluorescent
                WS_F10_OBS2     34       2°(CIE 1931)   ; Ultralume 50, Philips TL85
                WS_F10_OBS10    35       10°(CIE 1964)  ; Ultralume 50, Philips TL85
                WS_F11_OBS2     36       2°(CIE 1931)   ; Ultralume 40, Philips TL84
                WS_F11_OBS10    37       10°(CIE 1964)  ; Ultralume 40, Philips TL84
                WS_F12_OBS2     38       2°(CIE 1931)   ; Ultralume 30, Philips TL83
                WS_F12_OBS10    39       10°(CIE 1964)  ; Ultralume 30, Philips TL83

    Return Value:
        If the funtion suceeds, it will return TRUE. If fails, will return FALSE. The function will fail whenever
        you try to settled a Flag bigger then WS_F12_OBS10, since currently the maximum data available for the
        tristiumuls are the 10º observer for UltraLume30.

    Example of usage:
   
        [Ref_X: R$ 0]
        [Ref_Y: R$ 0]
        [Ref_Z: R$ 0]

            call FindWhiteRefEx Ref_X, Ref_Y, Ref_Z, WS_A_OBS10
   
    References:
   
        For more aditional information, see:
            http://www.easyrgb.com/en/math.php
            https://www.mathworks.com/matlabcentral/fileexchange/40640-computational-colour-science-using-matlab-2e
            https://en.wikipedia.org/wiki/Standard_illuminant

XYZ (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.0927     100.000     85.313      99.178      100.000     84.3493     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

;;
___________________________________________________________________________________________________________________________________

Proc FindWhiteRefEx:
    Arguments @pRefX, @pRefY, @pRefZ, @Flag
    Uses edx, ecx, ebx, esi

    xor eax eax
    On D@Flag > WS_F12_OBS10, ExitP

    xor edx edx
    mov eax Size_Of_WhiteSpace
    mul D@Flag
    mov esi WHITE_SPACE_A_X_OBS2
    add esi eax

    mov ebx D@pRefX | fld R$esi+WhiteSpaceXDis | fstp R$ebx
    mov ebx D@pRefY | fld R$esi+WhiteSpaceYDis | fstp R$ebx
    mov ebx D@pRefZ | fld R$esi+WhiteSpaceZDis | fstp R$ebx

    mov eax &TRUE

EndP
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com