level 1
glc1314521
楼主
背景色的点的坐标位置,说明一下,这个图片框里只有两种颜色,一白一红,白色为背景,红色是画的曲线,我想最终得到白色的像素点位置坐标记做0,红色像素点位置坐标记做1,最终得到一个500x500的矩阵,这个矩阵只有0和1……我是这样做的?可是代码总是会报错,请好心人帮我调试一下,我觉得没问题,可是找不出来
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i, j As Integer
Dim tmpbmp As New Bitmap(PictureBox2.Image)
PictureBox2.Image = tmpbmp
With tmpbmp
For j = 1 To .Height
For i = 1 To .Width
Dim p As Color
p = tmpbmp.GetPixel(i, j)
If 255 - p.R = RGB(255, 0, 0) Then
A(i, j) = 1
ListBox1.Items.Add(A(i, j))
'Else
'A(i, j) = 0
End If
Next
Next
End With
End Sub
2012年11月09日 08点11分
1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i, j As Integer
Dim tmpbmp As New Bitmap(PictureBox2.Image)
PictureBox2.Image = tmpbmp
With tmpbmp
For j = 1 To .Height
For i = 1 To .Width
Dim p As Color
p = tmpbmp.GetPixel(i, j)
If 255 - p.R = RGB(255, 0, 0) Then
A(i, j) = 1
ListBox1.Items.Add(A(i, j))
'Else
'A(i, j) = 0
End If
Next
Next
End With
End Sub