Tks dedndave
For the regular mean and standard deviations, i succeed to make. The problem is with this weight variable, covariance and Q attributes. I´m not being able to understand how to code them, because i don´t know how to analyse those mathematical formulas
For getting the regular standard deviation, i succedded making this:
[CieLabVariance:
CieLabVariance.Light: R$ 0
CieLabVariance.aFactor: R$ 0
CieLabVariance.bFactor: R$ 0
CieLabVariance.KFactor: R$ 0]
[CieLabMean:
CieLabMean.Light: R$ 0
CieLabMean.aFactor: R$ 0
CieLabMean.bFactor: R$ 0
CieLabMean.KFactor: R$ 0]
[CieLabStdDev:
CieLabStdDev.Light: R$ 0
CieLabStdDev.aFactor: R$ 0
CieLabStdDev.bFactor: R$ 0
CieLabStdDev.KFactor: R$ 0]
Proc GetCieLabStandardDeviation:
Arguments @pColorData, @ImgWidth, @ImgHeight
call CieLabGetMean D@pColorData, D@ImgWidth, D@ImgHeight, CieLabMean
call CieLabGetVariance D@pColorData, CieLabMean, D@ImgWidth, D@ImgHeight
finit
fld R$CieLabVariance.Light | fsqrt | fstp R$CieLabStdDev.Light
fld R$CieLabVariance.aFactor | fsqrt | fstp R$CieLabStdDev.aFactor
fld R$CieLabVariance.bFactor | fsqrt | fstp R$CieLabStdDev.bFactor
;fld R$CieLabVariance.KFactor | fsqrt | fstp R$StdDev.KFactor <------ weight ??????
EndP
Proc CieLabGetMean:
Arguments @pColorData, @ImgWidth, @ImgHeight, @pCieLabMeanStr
Local @iCounter, @Red, @Green, @Blue, @Y, @MaxCount, @MyPixelSrc, @MaxCount2
Structure @TempStorage 44, @HueDis 0, @SaturationDis 8, @LightDis 16, @LumaDis 24, @aFactorDis 32, @bFactorDis 40
Uses eax, ebx, ecx, esi, edi, edx
mov D@iCounter 0
mov D@MaxCount2 0
mov ebx D@ImgWidth
imul ebx D@ImgHeight
mov D@MaxCount ebx
finit
mov esi D@pColorData
.While D@iCounter < ebx
lea ebx D@Red | movzx edi B$esi+RGBTRIPLE.rgbtRedDis | mov D$ebx edi
lea edx D@Green | movzx edi B$esi+RGBTRIPLE.rgbtGreenDis | mov D$edx edi
lea ecx D@Blue | movzx edi B$esi+RGBTRIPLE.rgbtBlueDis | mov D$ecx edi
lea edi D@MyPixelSrc | mov D$edi 0
mov eax D@Red | mov B$edi+ARGB.RedDis al
mov eax D@Green | mov B$edi+ARGB.GreenDis al
mov eax D@Blue | mov B$edi+ARGB.BlueDis al
lea ebx D@HueDis | mov D$ebx 0 | mov D$ebx+4 0
lea edx D@SaturationDis | mov D$edx 0 | mov D$edx+4 0
lea ecx D@LightDis | mov D$ecx 0 | mov D$ecx+4 0
call RGBtoHSL edi, ebx, edx, ecx
...If eax <> 0 ; do not compute gray color
lea ebx D@LumaDis | mov D$ebx 0 | mov D$ebx+4 0
lea edx D@aFactorDis | mov D$edx 0 | mov D$edx+4 0
lea ecx D@bFactorDis | mov D$ecx 0 | mov D$ecx+4 0
call RGBtoCieLab D@Red, D@Green, D@Blue, ebx, edx, ecx
fld R$CieLabMean.Light | fadd R$ebx | fstp R$CieLabMean.Light
fld R$CieLabMean.aFactor | fadd R$edx | fstp R$CieLabMean.aFactor
fld R$CieLabMean.bFactor | fadd R$ecx | fstp R$CieLabMean.bFactor
;fld R$CieLabMean.bFactor | fdiv R$CieLabMean.aFactor | fadd R$CieLabMean.KFactor | fstp R$CieLabMean.KFactor
inc D@MaxCount2
...End_If
add esi 3
inc D@iCounter
mov ebx D@MaxCount
.End_While
fld R$CieLabMean.Light | fidiv F@MaxCount2 | fstp R$CieLabMean.Light
fld R$CieLabMean.aFactor | fidiv F@MaxCount2 | fstp R$CieLabMean.aFactor
fld R$CieLabMean.bFactor | fidiv F@MaxCount2 | fstp R$CieLabMean.bFactor
; fld R$CieLabMean.KFactor | fidiv F@MaxCount2 | fstp R$CieLabMean.KFactor
EndP
Proc CieLabGetVariance:
Arguments @pColorData, @pMean, @ImgWidth, @ImgHeight
Local @iCounter, @Red, @Green, @Blue, @Y, @MaxCount, @MyPixelSrc, @MaxCount2
Structure @TempStorage 44, @HueDis 0, @SaturationDis 8, @LightDis 16, @LumaDis 24, @aFactorDis 32, @bFactorDis 40
Uses eax, ebx, ecx, esi, edi, edx
finit
mov D@iCounter 0
mov D@MaxCount2 0
mov ebx D@ImgWidth
imul ebx D@ImgHeight
mov D@MaxCount ebx
mov esi D@pColorData
.While D@iCounter < ebx
lea ebx D@Red | movzx edi B$esi+RGBTRIPLE.rgbtRedDis | mov D$ebx edi
lea edx D@Green | movzx edi B$esi+RGBTRIPLE.rgbtGreenDis | mov D$edx edi
lea ecx D@Blue | movzx edi B$esi+RGBTRIPLE.rgbtBlueDis | mov D$ecx edi
lea edi D@MyPixelSrc | mov D$edi 0
mov eax D@Red | mov B$edi+ARGB.RedDis al
mov eax D@Green | mov B$edi+ARGB.GreenDis al
mov eax D@Blue | mov B$edi+ARGB.BlueDis al
lea ebx D@HueDis | mov D$ebx 0 | mov D$ebx+4 0
lea edx D@SaturationDis | mov D$edx 0 | mov D$edx+4 0
lea ecx D@LightDis | mov D$ecx 0 | mov D$ecx+4 0
call RGBtoHSL edi, ebx, edx, ecx
...If eax <> 0 ; do not compute gray color
lea ebx D@LumaDis | mov D$ebx 0 | mov D$ebx+4 0
lea edx D@aFactorDis | mov D$edx 0 | mov D$edx+4 0
lea ecx D@bFactorDis | mov D$ecx 0 | mov D$ecx+4 0
call RGBtoCieLab D@Red, D@Green, D@Blue, ebx, edx, ecx
fld R$CieLabMean.Light | fsub R$ebx | fabs | fmul ST0 | fadd R$CieLabVariance.Light | fstp R$CieLabVariance.Light
fld R$CieLabMean.aFactor | fsub R$edx | fabs | fmul ST0 | fadd R$CieLabVariance.aFactor | fstp R$CieLabVariance.aFactor
fld R$CieLabMean.bFactor | fsub R$ecx | fabs | fmul ST0 | fadd R$CieLabVariance.bFactor | fstp R$CieLabVariance.bFactor
;fdiv R$Variance.Saturation | fld R$Mean.KFactor | fsub ST1 | fabs | fmul ST0 | fadd R$Variance.KFactor | fstp R$Variance.KFactor
inc D@MaxCount2
...End_If
add esi 3
inc D@iCounter
mov ebx D@MaxCount
.End_While
fld R$CieLabVariance.Light | fidiv F@MaxCount2 | fstp R$CieLabVariance.Light
fld R$CieLabVariance.aFactor | fidiv F@MaxCount2 | fstp R$CieLabVariance.aFactor
fld R$CieLabVariance.bFactor | fidiv F@MaxCount2 | fstp R$CieLabVariance.bFactor
EndP
The GetCieLabStandardDeviation does not compute gray values. I´ll later make this as a variable and also make another variable to work with colors schemes different then D65, observer 2, such as D55, D50, observer 10 etc.
For now, i´m just testing the standard deviation and see how to implement it as the ones in the pdf with the weight and other variables.
Note: a few variables names are incorrect, cause i didn´t had time to fix that yet. Since i was trying to make it work the std dev i let some variables there even if they are unused.