平均值和标准偏差精度

时间:2014-05-07 16:39:08

标签: math image-processing vb6

我正在使用VB 6.0来计算图像红色通道的平均值和标准偏差。这些功能是正确的,但与其他应用程序配合使用时不正确。这是我写的代码: 例如,我的代码中的平均值= 240而其他应用程序它的差异很小,但我如何才能使其准确?

Sub TORGB(ByVal Col As Long, R As Double, G As Double, B As Double)
    R = Col And &HFF
    G = (Col \ &H100) And &HFF
    B = (Col \ &H10000) And &HFF   
End Sub 

Dim sumr As Single
Dim meanr As Single
Dim SDr As Single
sumr = 0
For y = 0 To Pic.ScaleHeight - 1
    For x = 0 To Pic.ScaleWidth - 1
                PixelValue = GetPixel(Pic.hdc, x, y)
                TORGB PixelValue, R, G, B
                sumr = sumr + R
Next x : Next y
si = Pic.ScaleWidth * Pic.ScaleHeight
meanr = sumr / si

0 个答案:

没有答案