Dim bm As New Bitmap(pbAfter.Image)
        Dim X As Integer
        Dim Y As Integer
        Dim clr As Integer

        For X = 0 To bm.Width - 1
            For Y = 0 To bm.Height - 1
                clr = (CInt(bm.GetPixel(X, Y).R) + _
                       bm.GetPixel(X, Y).G + _
                       bm.GetPixel(X, Y).B) \ 3
                bm.SetPixel(X, Y, Color.FromArgb(clr, clr, clr))
            Next Y
        Next X

        pbAfter.Image = bm

    End Sub

I don't understand the question. Are you looking for a grayscale conversion and edge detection algorithm? Are you looking for some undefined range of image processing that includes those? Please clarify.