2011-09-11 24 views
0

ocr 프로그램에서 사용하기 위해 이미지를 가변 임계 값에서 흑백으로 변경하려고합니다. 내 문제는 내가 처리 된 이미지에서 어떤 결과도 보이지 않는다는 것입니다. 나는 렌더링을 할 때 잠시 기다려 본다. 그래서 실제로 뭔가를하고 있다고 가정한다.왜 PictureBox에 결과가 표시되지 않습니까?

Imports System.Object 
Imports System.Drawing.Bitmap 

Public Class Form1 
    Dim x As Integer, y As Integer 
    Dim imgx As Integer, imgy As Integer 
    Dim img As Bitmap 
    Dim thresh As Bitmap 
    Dim pixelColor As Color 
    Dim threshcolor As Color 
    Dim tempcolor As Color 

    Public Function getpixel(ByRef x As Integer, ByRef y As Integer) As Color 

    End Function 

    Public Sub find_img_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles find_img.Click 
     open_img.ShowDialog() 
     img_dsp.Text = open_img.FileName() 
     img_loc.Text = open_img.FileName 
     img_dsp.ImageLocation = img_dsp.Text 
    End Sub 

    Public Sub find_img_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles find_img.LostFocus 
     img = (img_dsp.Image) 
     img_dsp.Refresh() 
     img_dsp.Text = open_img.FileName() 
     img_dsp.ImageLocation = img_dsp.Text 
     img = (img_dsp.Image) 
     img_dsp.Refresh() 
    End Sub 

    Public Sub render_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles render.Click 
     Dim myx As Integer 
     Dim myy As Integer 

     img_threshold.Image = img 
     thresh = img_threshold.Image 

     For myy = 1 To (img.Height - 1) 
      For myx = 1 To (img.Width - 1) 
       tempcolor = img.GetPixel(myx, myy) 

       If tempcolor.GetBrightness < NumericUpDown1.Value Then 
        thresh.SetPixel(x, y, Color.Black) 
       End If 

       If tempcolor.GetBrightness > NumericUpDown1.Value Then 
        thresh.SetPixel(x, y, Color.White) 
       End If 
      Next myx 
     Next myy 

     img_threshold.Image = thresh 
     img_threshold.Refresh() 
    End Sub 
End Class  
+0

죄송합니다.이 사이트는 '나를위한 내 코드 디버그'가 아닙니다. 정말로 누군가를 찾아 코드를 검토하는 것이 좋습니다. 친구의 팀원. 어쩌면 codereview.stackexchange.com, 확실하지 않습니다. –

+0

미안하지만, 나는 내 대학 프로젝트를 위해 자신을 가르치고 있는데, 내가하고있는 일이 뻔뻔스럽게 잘못되어 있는지 묻고 있었다. –

답변

0

참조가 무엇인지 알고 있습니까? A = B를 쓰고 A를 변경하고 B = A를 쓰는가? A와 B가 동일한 객체 (같은 객체에 대한 참조)를 가리 키도록 지정하면 다른 객체도 변경되며 메모리의 동일한 저장소를 차지합니다! 프로그램을 작성하기 전에 자신을 기본으로 가르쳐주십시오.

관련 문제