Вот код.
- Код: Выделить всё
' y=(x*cos(theta)+rho)/sin(theta)
Const pi = 3.14
Private Sub Picture1_Click()
Dim x, y, i, j As Integer
Dim Teta, R As Integer
Dim w, h
Dim maxR As Integer
Dim ReS() As Integer, MaxV As Integer
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
maxR = Round(Sqr(w * w + h * h))
ReDim ReS(180, maxR) As Integer
Teta = 0
For y = 0 To h
For x = 0 To w
If Picture1.Point(x, y) <> vbWhite Then
'\\\\\
For i = 0 To 179
For j = 0 To maxR - 1
Teta = i * pi / 180
If Abs((y * Sin(Teta) + x * Cos(Teta)) - j) < 0.1 Then ReS(i, j) = ReS(i, j) + 1
Next j
Next i
'\\\\\
End If
Next x
Next y
MaxV = 0
Teta = 0
R = 0
For i = 0 To 179
For j = 0 To maxR - 1
If ReS(i, j) > MaxV Then MaxV = ReS(i, j)
Teta = i
R = j
Next j
Next i
Teta = Teta * pi / 180
For y = 0 To h
For x = 0 To w
If Round(y * Sin(Teta) + x * Cos(Teta)) = R Then Picture1.PSet (x, y), vbRed
Next x
Next y
Picture1.Refresh
'Erase Res
End Sub