カラー画像をモノクロ画像に変更する

        Dim img As Bitmap
        Dim x As Integer, y As Integer
        Dim ix As Integer, iy As Integer
        Dim c As Color, ic As Integer
        img = PictureBox1.Image
        If img IsNot Nothing Then
            x = img.Width
            y = img.Height
            For ix = 0 To x - 1
                For iy = 0 To y - 1
                    c = img.GetPixel(ix, iy)
                    ic = (c.R * 306 + c.G * 601 + c.B * 117) >> 10
                    c = Color.FromArgb(ic, ic, ic)
                    img.SetPixel(ix, iy, c)
                Next
            Next
            PictureBox1.Image = img
        End If