Win8 Metro(C#)数字图像处理--2.69中点滤波器

[函数代码]



<strong>        /// <summary>
        /// Mid-point filter.
        /// </summary>
        /// <param name="src">The source image.</param>
        /// <returns></returns>
        public static WriteableBitmap MidPointFilterProcess(WriteableBitmap src)中点滤波器
        {
            if (src != null)
            {
                int w = src.PixelWidth;
                int h = src.PixelHeight;
                WriteableBitmap filterImage = new WriteableBitmap(w, h);
                byte[] temp = src.PixelBuffer.ToArray();
                byte[] tempMask = (byte[])temp.Clone();
                double[] Gray = new double[9];
                double gray = 255, graymax = 0;
                int tempr = 0, tempb = 0, tempg = 0, temprMax = 0, tempgMax = 0, tempbMax = 0;
                for (int j = 1; j < h - 1; j++)
                {
                    for (int i = 1; i < w - 1; i++)
                    {
                        tempb = 0;
                        tempg = 0;
                        tempr = 0;
                        gray = 255;
                        graymax = 0;
                        int[] B = new int[9] { tempMask[i * 4 + j * w * 4], tempMask[(i - 1) * 4 + (j - 1) * w * 4], tempMask[i * 4 + (j - 1) * w * 4], tempMask[(i + 1) * 4 + (j - 1) * w * 4], tempMask[(i - 1) * 4 + j * w * 4], tempMask[(i + 1) * 4 + j * w * 4], tempMask[(i - 1) * 4 + (j + 1) * w * 4], tempMask[i * 4 + (j + 1) * w * 4], tempMask[(i + 1) * 4 + (j + 1) * w * 4] };
                        int[] G = new int[9] { tempMask[i * 4 + 1 + j * w * 4], tempMask[(i - 1) * 4 + 1 + (j - 1) * w * 4], tempMask[i * 4 + 1 + (j - 1) * w * 4], tempMask[(i + 1) * 4 + 1 + (j - 1) * w * 4], tempMask[(i - 1) * 4 + 1 + j * w * 4], tempMask[(i + 1) * 4 + 1 + j * w * 4], tempMask[(i - 1) * 4 + 1 + (j + 1) * w * 4], tempMask[i * 4 + 1 + (j + 1) * w * 4], tempMask[(i + 1) * 4 + 1 + (j + 1) * w * 4] };
                        int[] R = new int[9] { tempMask[i * 4 + 2 + j * w * 4], tempMask[(i - 1) * 4 + 2 + (j - 1) * w * 4], tempMask[i * 4 + 2 + (j - 1) * w * 4], tempMask[(i + 1) * 4 + 2 + (j - 1) * w * 4], tempMask[(i - 1) * 4 + 2 + j * w * 4], tempMask[(i + 1) * 4 + 2 + j * w * 4], tempMask[(i - 1) * 4 + 2 + (j + 1) * w * 4], tempMask[i * 4 + 2 + (j + 1) * w * 4], tempMask[(i + 1) * 4 + 2 + (j + 1) * w * 4] };
                        for (int n = 0; n < 9; n++)
                        {
                            Gray[n] = (double)B[n] * 0.114 + (double)G[n] * 0.587 + (double)R[n] * 0.299;
                            if (gray > Gray[n])
                            {
                                gray = Gray[n];
                                tempb = B[n];
                                tempr = R[n];
                                tempg = G[n];
                            }
                            if (graymax < Gray[n])
                            {
                                graymax = Gray[n];
                                tempbMax = B[n];
                                tempgMax = G[n];
                                temprMax = R[n];
                            }
                        }
                        temp[i * 4 + j * w * 4] = (byte)((tempb + tempbMax) / 2);
                        temp[i * 4 + 1 + j * w * 4] = (byte)((tempg + tempgMax) / 2);
                        temp[i * 4 + 2 + j * w * 4] = (byte)((tempr + temprMax) / 2);
                    }
                }
                Stream sTemp = filterImage.PixelBuffer.AsStream();
                sTemp.Seek(0, SeekOrigin.Begin);
                sTemp.Write(temp, 0, w * 4 * h);
                return filterImage;
            }
            else
            {
                return null;
            }
        }</strong>

[图像效果]


最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:




  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
make: Leaving directory '/home/wanglangtao/frifly/rk3399_linux_release_v2.5.1_20210301/buildroot' 2023-06-07T03:54:43 >>> host-gcc-initial 8.4.0 Building 2023-06-07T03:54:47 >>> host-gcc-initial 8.4.0 Installing to host directory 2023-06-07T03:54:49 >>> host-libtool 2.4.6 Extracting 2023-06-07T03:54:50 >>> host-libtool 2.4.6 Patching 2023-06-07T03:54:50 >>> host-libtool 2.4.6 Updating config.sub and config.guess 2023-06-07T03:54:50 >>> host-libtool 2.4.6 Configuring 2023-06-07T03:54:53 >>> host-libtool 2.4.6 Building 2023-06-07T03:54:54 >>> host-libtool 2.4.6 Installing to host directory 2023-06-07T03:54:55 >>> host-autoconf 2.69 Extracting 2023-06-07T03:54:55 >>> host-autoconf 2.69 Patching 2023-06-07T03:54:55 >>> host-autoconf 2.69 Updating config.sub and config.guess 2023-06-07T03:54:55 >>> host-autoconf 2.69 Patching libtool 2023-06-07T03:54:55 >>> host-autoconf 2.69 Configuring 2023-06-07T03:54:56 >>> host-autoconf 2.69 Building 2023-06-07T03:54:57 >>> host-autoconf 2.69 Installing to host directory 2023-06-07T03:54:57 >>> host-automake 1.15.1 Extracting 2023-06-07T03:54:57 >>> host-automake 1.15.1 Patching 2023-06-07T03:54:57 >>> host-automake 1.15.1 Updating config.sub and config.guess 2023-06-07T03:54:57 >>> host-automake 1.15.1 Patching libtool 2023-06-07T03:54:58 >>> host-automake 1.15.1 Configuring 2023-06-07T03:54:59 >>> host-automake 1.15.1 Building 2023-06-07T03:54:59 >>> host-automake 1.15.1 Installing to host directory 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Extracting 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Patching 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Updating config.sub and config.guess 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Patching libtool 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Configuring 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Building 2023-06-07T03:55:01 >>> host-pkgconf 0.9.12 Installing to host directory 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Extracting 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Patching 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Updating config.sub and config.guess 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Patching libtool 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Configuring 2023-06-07T03:55:06 >>> host-libxml2 2.9.7 Building 2023-06-07T03:55:22 >>> host-libxml2 2.9.7 Installing to host directory 2023-06-07T03:55:24 >>> host-gettext 0.19.8.1 Extracting 2023-06-07T03:55:25 >>> host-gettext 0.19.8.1 Patching 2023-06-07T03:55:26 >>> host-gettext 0.19.8.1 Updating config.sub and config.guess 2023-06-07T03:55:26 >>> host-gettext 0.19.8.1 Configuring 2023-06-07T03:55:26 >>> host-gettext 0.19.8.1 Autoreconfiguring 2023-06-07T03:55:51 >>> host-gettext 0.19.8.1 Patching libtool 2023-06-07T03:56:13 >>> host-gettext 0.19.8.1 Building什么问题
最新发布
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Trent1985

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值