Sharpen on a Bitmap using C#

前端 未结 6 1554
庸人自扰
庸人自扰 2020-12-02 14:45

I want to put a sharpen filter on an image. I have found a web with short tutorial. I tried to do it in C# so here is my code. Anyway, I tried to find out why it is not work

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 15:26

    This will create a softer sharpening effect. You can expand the filter array if you need to, or change the 16 to something larger, but I found this isn't as harsh as the one you have.

    const int filterWidth = 5;
    const int filterHeight = 5;
    
    double[,] filter = new double[filterWidth,filterHeight] {
        { -1, -1, -1, -1, -1 },
        { -1,  2,  2,  2, -1 },
        { -1,  2,  16,  2, -1 },
        { -1,  2,  2,  2, -1 },
        { -1, -1, -1, -1, -1 }
    };
    
    double factor = 1.0 / 16.0;
    

提交回复
热议问题