zoukankan      html  css  js  c++  java
  • 【Emgucv】图像卷积(TEST)

    1. 使用3×3的核进行卷积实现浮雕效果

    -1 , -1 ,0

    -1 , 0 , 1

    0 , 1 ,1

     double[,] h = { { -1, -1, 0 }, { -1, 0, 1 }, { 0, 1, 1 } };
      private Image<Bgr,byte> Juanji(Image<Bgr,byte>pic)
            {
                Image<Bgr, byte> output = new Image<Bgr, byte>(pic.Size);
                double[,] h = { { -1, -1, 0 }, { -1, 0, 1 }, { 0, 1, 1 } };
                double b = 0, g = 0, r = 0;
                for (int i=1;i<pic.Width-1;i++)
                {
                    for(int j = 1; j < pic.Height-1; j++)
                    {
                        b = 0;g = 0;r = 0;
                        for(int m = -1; m <= 1; m++)
                        {
                            for(int n = -1; n <= 1; n++)
                            {
                                b += pic[j+m, i+n].Blue * h[m + 1, n + 1];
                                g += pic[j + m, i + n].Green * h[m + 1, n + 1];
                                r += pic[j + m, i + n].Red * h[m + 1, n + 1];
                            }
                        }
                        output[j, i] = new Bgr(b,g,r);
                    }
                }
                return output;
            }       

    这里写图片描述

  • 相关阅读:
    12
    11
    10
    9
    8
    7
    6
    5
    4
    3
  • 原文地址:https://www.cnblogs.com/cnsec/p/13286764.html
Copyright © 2011-2022 走看看