A simple solution would be the following:
- Find the first top horizontal line containing white pixels.
- From this line, find the first horizontal line containing only black pixels
- .
:
- .
.
, , .
- VB.net, :
Sub FindTopBorder(image As MyImage) As Integer
For y = 0 to image.Height - 1
For x = 0 to image.Width - 1
Dim pixel = image.GetPixel(x, y)
If ('Check if pixel is white here with RGB or Color') Then
Return y
End If
Next
Next
' Just in case there are no white pixels or use an exception instead
Return -1
End Sub