Public Class Form1 #Region "フィールド(定数)" ' 画像のパス Private Const STRING_IMAGE_PATH As String = "C:\Users\owner\Pictures\test.bmp" ' 画像の保存パス Private Const STRING_SAVE_PATH As String = "C:\Users\owner\Pictures\test2.bmp" #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Using img As Image = Image.FromFile(STRING_IMAGE_PATH) With PictureBox1 .Width = img.Width .Height = img.Height End With ' 幅 Dim iWidth As Integer = PictureBox1.ClientRectangle.Width ' 高さ Dim iHeight As Integer = PictureBox1.ClientRectangle.Height If PictureBox1.Image Is Nothing Then PictureBox1.Image = New Bitmap(iWidth, iHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb) End If Using g As Graphics = Graphics.FromImage(PictureBox1.Image) ' 閾値の変更 Dim matrix As New System.Drawing.Imaging.ColorMatrix() matrix.Matrix00 = 1 matrix.Matrix11 = 1 matrix.Matrix22 = 1 matrix.Matrix33 = 0.5F matrix.Matrix44 = 1 ' 閾値を設定 Dim attr As New System.Drawing.Imaging.ImageAttributes() attr.SetColorMatrix(matrix) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height), _ 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, attr) ' 保存 PictureBox1.Image.Save(STRING_SAVE_PATH) End Using End Using End Sub End Class