Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Detect rectangle in image

$
0
0
Name:  F0A2.jpg
Views: 83
Size:  5.0 KB

Hello,
I would detect the rectangle in image like image in attachments usually i use this below code in do that also you can check on full example in attachments.

Code:

Private Function GetHorizontalLines(ByVal Img As Bitmap, ByVal StartX As Integer, ByVal StartY As Integer) As ArrayList
        Dim Points As New ArrayList
        Dim mCount As Integer = 0
        For Y = StartY To Img.Height - 10
            For X = StartX To Img.Width - 10
                Application.DoEvents()
                Dim C As Color = Img.GetPixel(X, Y)
                If C.A = 255 Then
                    If mCount > 140 Then GoTo Founded
                    If C.B < 75 AndAlso C.G < 75 AndAlso C.R < 75 Then
         
                        mCount += 1
                        Points.Add(New Point(X, Y))
                    Else
                        Points.Clear()
                        mCount = 0
                    End If
                End If
            Next
        Next
        Return Nothing
        Exit Function
Founded:
        Return Points
    End Function


This code will working if rectangle have clear border but the problem here the image background is black and no clear frame to the rectangle i tried change in color code but no result also i tried find examples to do like i want but a lot of lines and many DLL files without a good result i need do that Simply.

Thanks in advance:)
Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>