Hallo, ich habe hier ein kleines problem, und komme nicht drauf wocher das kommt:
hab eine webcam, da nehme ich ein bild mit auf:
so, das bild ist in der picbox1. so jetzt will ich das bild binär haben und picbox2 abspeichern. damit ich das bild binärisieren kann, hab ich das in einen neuen bild kopiert:
ps. funkt2 zeigt auf die getBmp1()
so, so weit so gut. jetzt habe ich zwei bilder, in zwei picboxen. das eine ist farbig, das andere binär.
jetzt kommt meine frage:
wenn ich jetzt das binäre bild noch einmal kopiere und damit noch was mache, ändert es die picbox2 und picbox3. und ich komm nicht auf dem fehler. mein hintergrundprozess sieht so aus:
ich habe sogar schon einfach mal zu probe:bmp_new = bmp_origenal, und danach mache ich mit dem bmp_new nichts und dennoch zeigt er beide picboxen (2 und 3) das binäre bild.
kann mir jemand helfen?
hab eine webcam, da nehme ich ein bild mit auf:
so, das bild ist in der picbox1. so jetzt will ich das bild binär haben und picbox2 abspeichern. damit ich das bild binärisieren kann, hab ich das in einen neuen bild kopiert:
ps. funkt2 zeigt auf die getBmp1()
so, so weit so gut. jetzt habe ich zwei bilder, in zwei picboxen. das eine ist farbig, das andere binär.
jetzt kommt meine frage:
wenn ich jetzt das binäre bild noch einmal kopiere und damit noch was mache, ändert es die picbox2 und picbox3. und ich komm nicht auf dem fehler. mein hintergrundprozess sieht so aus:
ich habe sogar schon einfach mal zu probe:bmp_new = bmp_origenal, und danach mache ich mit dem bmp_new nichts und dennoch zeigt er beide picboxen (2 und 3) das binäre bild.
Quellcode
- Dim funk1 As New funktion1(AddressOf owner.changBild)
- Dim funk2 As New funktion2(AddressOf owner.getBmp1)
- Dim bmp_origenal As Bitmap
- Dim bmp_binaer As Bitmap
- Dim bmp_old As Bitmap
- Dim bmp_new As Bitmap
- Dim x, y As System.Drawing.Color
- Dim i, j, r, g, b, ans, h As Integer
- Dim erkannt As Boolean = False
- 'owner.PictureBox2.Image = owner.webcam.CapturePicture(owner.webcam.videoHandle)
- bmp_origenal = owner.Invoke(funk2)
- bmp_binaer = bmp_origenal
- bmp_new = bmp_origenal
- bmp_old = bmp_origenal
- While True
- bmp_origenal = owner.Invoke(funk2)
- bmp_binaer = bmp_origenal
- bmp_new = bmp_origenal
- i = 0
- Do
- Do
- x = bmp_binaer.GetPixel(j, i)
- r = Convert.ToInt16(x.R)
- g = Convert.ToInt16(x.G)
- b = Convert.ToInt16(x.B)
- If r > 250 And erkannt = False Then
- x = Color.FromArgb(255, 0, 0)
- bmp_binaer.SetPixel(j, i, x)
- For h = -10 To 10
- If (j + h > 0) And (j + h < bmp_binaer.Width) Then bmp_binaer.SetPixel(j + h, i, x)
- If (i + h > 0) And (i + h < bmp_binaer.Height) Then bmp_binaer.SetPixel(j, i + h, x)
- Next
- erkannt = True
- Else
- ans = ((r + (g + b)) / 3)
- If (ans > 128) Then
- r = 255
- g = 255
- b = 255
- Else
- r = 0
- g = 0
- b = 0
- End If
- x = Color.FromArgb(r, g, b)
- bmp_binaer.SetPixel(j, i, x)
- End If
- j += 1
- Loop While j < bmp_binaer.Width
- j = 0
- i += 1
- Loop While i < bmp_binaer.Height
- For i = -50 To 50
- bmp_binaer.SetPixel(bmp_binaer.Width / 2 + i, bmp_binaer.Height / 2, Color.Blue)
- bmp_binaer.SetPixel(bmp_binaer.Width / 2, bmp_binaer.Height / 2 + i, Color.Blue)
- Next
- erkannt = False
- bmp_new = bmp_origenal
- Do
- Do
- x = bmp_new.GetPixel(j, i)
- 'y = bmp_old.GetPixel(j, i)
- If x <> y Then
- x = Color.FromArgb(255, 255, 255)
- 'bmp_new.SetPixel(j, i, x)
- End If
- j += 1
- Loop While j < bmp_binaer.Width
- j = 0
- i += 1
- Loop While i < bmp_binaer.Height
- owner.Invoke(funk1, bmp_origenal, bmp_binaer, bmp_new)
- End While
- End Sub
kann mir jemand helfen?