Forum: VB.NET |
Thema:
Laserlinie |
Von:
G. Guest (
03.02.2006 19:50) |
So... habe jetzt mal kruz versucht die halbe Funktion zu schreiben. Der restlcihe Verfahrensweise wäre mir klar. Könnte mir bitte nur mal kurz jemand sagen, ob der Folgende Code in der Array intLaserPosition() die Positionen der Maximalen Rotwerte für jede Spalte zweier Bilder angibt? Danke!
Public Sub Entfernungsberechnungschnell(ByVal strPfadBildMit As String, ByVal strPfadBildOhne As String, ByVal intAktuellerSchnitt As Integer)
Dim x, y As Integer
Dim rect As New Rectangle(intRandOben, intRandLinks, 2048 - intRandUnten - intRandOben, 1536 - intRandLinks - intRandRechts)
Dim bytes = (2048 - intRandUnten - intRandOben) * (1536 - intRandLinks - intRandRechts) * 3
Dim PixelsBildMit(bytes - 1) As Byte
Dim PixelsBildOhne(bytes - 1) As Byte
Dim bmpBildMit As Bitmap = New Bitmap(strPfadBildMit)
Dim bmpBildMitData As System.Drawing.Imaging.BitmapData = bmpBildMit.LockBits(rect, Imaging.ImageLockMode.ReadOnly, bmpBildMit.PixelFormat) 'Format?
Dim ptrBildMit As IntPtr = bmpBildMitData.Scan0
Dim bmpBildOhne As Bitmap = New Bitmap(strPfadBildOhne)
Dim bmpBildOhneData As System.Drawing.Imaging.BitmapData = bmpBildOhne.LockBits(rect, Imaging.ImageLockMode.ReadOnly, bmpBildOhne.PixelFormat) 'Format?
Dim ptrBildOhne As IntPtr = bmpBildOhneData.Scan0
Dim Width As Integer = bmpBildMitData.Width
Dim Height As Integer = bmpBildMitData.Height
Dim Stride As Integer = bmpBildMitData.Stride
Dim intRotDifferenz As Integer
Dim byteRotMax As Byte
Dim intLaserPosition(Width) As Integer
Dim loc As Integer
Marshal.Copy(ptrBildMit, PixelsBildMit, 0, bytes)
Marshal.Copy(ptrBildOhne, PixelsBildOhne, 0, bytes)
For x = 0 To Width
byteRotMax = 0
For y = 0 To Height
loc = y * Stride + x * 3 + 2
intRotDifferenz = PixelsBildMit(loc) - PixelsBildOhne(loc)
If intRotDifferenz > 30 And intRotDifferenz > byteRotMax Then
intLaserPosition(x) = y
byteRotMax = intRotDifferenz
End If
Next
Next
End Sub
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!