Nach einer Stunde versucht, dieses Problem zu lösen, entschied ich mich als eine Frage.VB Rückkehr Überlauf mit kleinen Zahlen
Ich verwende VB.Net 2010 in einem Image-Projekt. In diesem Schritt muss ich die Farbe der Pixel zweier Bilder vergleichen, um festzustellen, wie ähnlich sie sind. Um dies zu tun entwarf ich den folgenden Code:
''get both images as bitmaps
Dim act As New Bitmap("cam.bmp")
Dim map As New Bitmap(bmap)
''declare the variable that counts the different pixels
Dim count As Integer = 0
''declare the variables that represent the colors
Dim val As Long = 0
Dim valr As Long = 0
Dim valg As Long = 0
Dim valb As Long = 0
''analize both images pixel by pixel
For x = 1 To act.Width - 1 Step 1
For y = 1 To act.Height - 1 Step 1
valr = 0
valg = 0
valb = 0
''determine how different the pixels are
valr = Math.Abs(act.GetPixel(x, y).R - map.GetPixel(x, y).R)
valg = Math.Abs(act.GetPixel(x, y).G - map.GetPixel(x, y).G)
valb = Math.Abs(act.GetPixel(x, y).B - map.GetPixel(x, y).B)
val = Long.Parse(Int((valr + valg + valb)/3).ToString)
''if enough different, add 1 to count
If val > 50 Then
count += 1
End If
Next
Next
''show how many pixels are different in proportion
MsgBox((count/(act.Width * act.Height)).ToString)
Wenn dieser Code ausgeführt wird, tritt ein Überlauf im valr = Math.Abs(act.GetPixel(x, y).R - map.GetPixel(x, y).R)
Teil. Kein anderes Problem tritt auf.
Danke !, löste es mein Problem. – Elemermelada