ocr プログラムで使用するために、可変しきい値で画像を白黒に変更しようとしています。私の問題は、処理されたと思われる画像に結果が表示されないことです。レンダリング時に少し待機が発生するので、実際に何かを行っていると想定しています。
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