21-01-16, 02:27 PM
(آخر تعديل لهذه المشاركة : 21-01-16, 02:28 PM {2} بواسطة silverlight.)
أعتقد ان مشكلتك تكمن في الكود الخاص بعملية تحويل الصورة لا غير و طبعا البرامج المستخدمة علي النت و التي تقوم بتحويل الكود لا تراعي اخطاء البرمجة أصلا عند التحويل من لغة الي لغة أخري
عموما عليك فقط ان تعيد صياغه الدالة التي تقوم بعملية تحويل الصورة لتكتب بالشكل التالي
عموما عليك فقط ان تعيد صياغه الدالة التي تقوم بعملية تحويل الصورة لتكتب بالشكل التالي
PHP كود :
Public Function ConvertImage(im As Image) As Image
Dim gx As Integer(,) = New Integer(,) {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}
' The matrix Gx
Dim gy As Integer(,) = New Integer(,) {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}}
' The matrix Gy
Dim b As Bitmap = DirectCast(im, Bitmap)
Dim b1 As New Bitmap(im)
For i As Integer = 1 To b.Height - 2
' loop for the image pixels height
For j As Integer = 1 To b.Width - 2
' loop for image pixels width
Dim new_x As Single = 0, new_y As Single = 0
Dim c As Single
For hw As Integer = -1 To 1
'loop for cov matrix
For wi As Integer = -1 To 1
Dim bColor As Color = b.GetPixel(j + wi, i + hw)
Dim rColor As Color = b.GetPixel(j + wi, i + hw)
Dim gColor As Color = b.GetPixel(j + wi, i + hw)
c = CSng(Math.Min(bColor.B, 255) + Math.Min(rColor.R, 255) + Math.Min(gColor.G, 255)) / 3
new_x += gx(hw + 1, wi + 1) * (c)
new_y += gy(hw + 1, wi + 1) * (c)
Next
Next
If new_x * new_x + new_y * new_y > 128 * 128 Then
b1.SetPixel(j, i, Color.Black)
Else
b1.SetPixel(j, i, Color.White)
End If
Next
Next
Return DirectCast(b1, Image)
End Function

