I'm using this code to calculate the average color of an image but this is not working as desired. The result is inaccurate. How to find the average color of the image ?
Private Sub btnAvg_Click() Handles btnAvg.Click
Dim x, y As Integer
bmp = New Bitmap(picBox.Tag.ToString)
For y = picBox.Top To picBox.Bottom
For x = picBox.Left To picBox.Right
With bmp.GetPixel(x, y)
totalR = totalR + .R : totalG = totalG + .G : totalB = totalB + .B
End With
Next x
Next y
avgR = totalR / ((picBox.Bottom - picBox.Top) * (picBox.Right - picBox.Left))
avgG = totalG / ((picBox.Bottom - picBox.Top) * (picBox.Right - picBox.Left))
avgB = totalB / ((picBox.Bottom - picBox.Top) * (picBox.Right - picBox.Left))
End Sub
I'm looking for a hi-speed, more than 80% accurate result. This is not a duplicate question as other questions deals with C# only