منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
تحديد مركز الدائرة فى صورة - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : تحديد مركز الدائرة فى صورة (/showthread.php?tid=24034)



تحديد مركز الدائرة فى صورة - mrnooo2000 - 02-03-18

السلام عليكم

أخباركم شباب

اذا كان عندى صورة من لون معين و ليكن أزرق و بها دوائر صغيرة بلون أسود 
المطلوب 
 تحديد الدوائر و مركز كلا منها

[attachment=17252]

شكرا مقدما


RE: تحديد مركز الدائرة فى صورة - silverlight - 02-03-18

عليك البحث علي النت عن موضوعات تتحدث عن Pixel Scan

ممكن تبدأ من الرابط التالي

اللينك


RE: تحديد مركز الدائرة فى صورة - mrnooo2000 - 02-03-18

اخى الفاضل
ليست المشكلة فى عمل  pixel scan

المشكلة فى تحديد حواف الدائرة و من ثم تحديد مركزها


RE: تحديد مركز الدائرة فى صورة - mrnooo2000 - 06-03-18

ما وصلت اليه الى الان 
هو عمل قق لايجاد ثلاث نقاط على محيط الدائرة
من خلال تلك النقاط  يتم حساب مركز الدائرة و نصف قطرها باستخدام الكود التالى 


كود :
   'Find a circle through the three points.
   Private Sub FindCircle(ByVal a As PointF, ByVal b As PointF, ByVal c As PointF, ByRef center As PointF, ByRef radius As Single)
       ' Get the perpendicular bisector of (x1, y1) and (x2, y2).
       Dim x1 As Single = (b.X + a.X) / 2
       Dim y1 As Single = (b.Y + a.Y) / 2
       Dim dy1 As Single = b.X - a.X
       Dim dx1 As Single = -(b.Y - a.Y)

       ' Get the perpendicular bisector of (x2, y2) and (x3, y3).
       Dim x2 As Single = (c.X + b.X) / 2
       Dim y2 As Single = (c.Y + b.Y) / 2
       Dim dy2 As Single = c.X - b.X
       Dim dx2 As Single = -(c.Y - b.Y)

       ' See where the lines intersect.
       Dim lines_intersect, segments_intersect As Boolean
       Dim intersection, close1, close2 As PointF
       FindIntersection(New PointF(x1, y1), New PointF(x1 + dx1, y1 + dy1), New PointF(x2, y2), New PointF(x2 + dx2, y2 + dy2), lines_intersect, segments_intersect, intersection, close1, close2)
       If Not lines_intersect Then
           MessageBox.Show("The points are colinear")
           center = New PointF(0, 0)
           radius = 0
       Else
           center = intersection
           Dim dx As Single = center.X - a.X
           Dim dy As Single = center.Y - a.Y
           radius = CSng(Math.Sqrt(dx * dx + dy * dy))
       End If
   End Sub
   ' Find the point of intersection between the lines p1 --> p2 and p3 --> p4.
   Private Sub FindIntersection(ByVal p1 As PointF, ByVal p2 As PointF, ByVal p3 As PointF, ByVal p4 As PointF, ByRef lines_intersect As Boolean, ByRef segments_intersect As Boolean, ByRef intersection As PointF, ByRef close_p1 As PointF, ByRef close_p2 As PointF)
       ' Get the segments' parameters.
       Dim dx12 As Single = p2.X - p1.X
       Dim dy12 As Single = p2.Y - p1.Y
       Dim dx34 As Single = p4.X - p3.X
       Dim dy34 As Single = p4.Y - p3.Y

       ' Solve for t1 and t2
       Dim denominator As Single = (dy12 * dx34 - dx12 * dy34)

       Dim t1 As Single = ((p1.X - p3.X) * dy34 + (p3.Y - p1.Y) * dx34) / denominator
       If Single.IsInfinity(t1) Then
           ' The lines are parallel (or close enough to it).
           lines_intersect = False
           segments_intersect = False
           intersection = New PointF(Single.NaN, Single.NaN)
           close_p1 = New PointF(Single.NaN, Single.NaN)
           close_p2 = New PointF(Single.NaN, Single.NaN)
           Return
       End If
       lines_intersect = True

       Dim t2 As Single = ((p3.X - p1.X) * dy12 + (p1.Y - p3.Y) * dx12) / -denominator

       ' Find the point of intersection.
       intersection = New PointF(p1.X + dx12 * t1, p1.Y + dy12 * t1)

       ' The segments intersect if t1 and t2 are between 0 and 1.
       segments_intersect = ((t1 >= 0) AndAlso (t1 <= 1) AndAlso (t2 >= 0) AndAlso (t2 <= 1))

       ' Find the closest points on the segments.
       If t1 < 0 Then
           t1 = 0
       ElseIf t1 > 1 Then
           t1 = 1
       End If

       If t2 < 0 Then
           t2 = 0
       ElseIf t2 > 1 Then
           t2 = 1
       End If

       close_p1 = New PointF(p1.X + dx12 * t1, p1.Y + dy12 * t1)
       close_p2 = New PointF(p3.X + dx34 * t2, p3.Y + dy34 * t2)
   End Sub



RE: تحديد مركز الدائرة فى صورة - عبدالله الدوسري - 06-03-18

Emgu CV



emgu cv circle detection