Color difference

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Color difference
M1z23R
Again me....
I am making Motion Detection, and i have three picBox's, one for current preview, one for 'last frame' (5secs ago frame) and one for difference between those two.
Now, my camera and i belive every others gets picture (frame) with different brightness every time. When i use simple code to compare each pixel in first two image box's, only a few stay the same(10 out of 150*150). Other pixels are let's say 5% diffrent, darker or lighter. How could i fix this ?

Edit:
I even tried to check each pixel in one picture with 5 pixels in different picture (x,y)=(x,y)
(x,y)=(x+1,y)
(x,y)=(x,y+1)
(x,y)=(x,y-1)
(x,y)=(x-1,y)

Still not much difference.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Color difference
MrAksel
You could have a threshold.
Code: Select all
   Dim Treshold As Byte = 5
   Dim rDifference As Byte = Math.Abs(OldRed - NewRed)
   Dim gDifference As Byte = Math.Abs(OldGreen - NewGreen)
   Dim bDifference As Byte = Math.Abs(OldBlue - NewBlue)
   If rDifference > Treshold Then
      'Red value has changed more than 5 pixels'
   End If
   If gDifference > Treshold Then
      'Green value has changed more than 5 pixels'
   End If
   If bDifference > Treshold Then
      'Blue value has changed more than 5 pixels'
   End If
Just edit the value of 'Threshold' to fit your needs. Larger values means that bigger changes are accepted, smaller values means that the pixels only have to change a little bit for it to accept.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Color difference
M1z23R
I did exactly the same if you believe me :D
My function uses two colors, gets it's argb and gets difference between each (A,R,G,B) and if it's combined difference is less then 35 it returns that they are same.

Thank you btw, +rep you
3 posts Page 1 of 1
Return to “Coding Help & Support”