zoukankan      html  css  js  c++  java
  • Emgu.CV(三)

    像素交换

    private void btn_Exchange_Click(object sender, EventArgs e)
            {
                if (imageBox1.Image != null)
                {
                    var image = (Image<Bgr, Byte>)imageBox1.Image;
                    ExChangePixelValue(image);
                    imageBox1.Image = image;
                }
            }
     public  void ExChangePixelValue(Image<Bgr, Byte> image)
            {
    //这两个值视图片大小而定
                for (int i = 0; i < 500; i++)
                {
                    for (int j = 0; j < 1000; j++)
                    {
                        Bgr tmp = image[i, j];
                        image[i, j] = image[i + 500, j + 500];
                        image[i + 500, j + 500] = tmp;
                    }
                }
            }
    

      

    图片自加

    private void btn_Add_Click(object sender, EventArgs e)
            {        
                var image= new Image<Bgr, byte>(@"D:1.jpg");
                //图片自加
                imageBox2.Image = image.Add(image);
            }
    

      

    图片自减

    private void btn_Sub_Click(object sender, EventArgs e)
            {
                var image = new Image<Bgr, byte>(_img);
                //图片自减
                var rect = new Rectangle(new Point(0, 0), new Size(image.Width / 2, image.Height));
                using (var mask = new Image<Gray, Byte>(image.Size))
                {
                    mask.SetZero();//设置所有值为0
                    mask.ROI = rect;
                    mask.SetValue(255);//设置ROI的值为255
                    mask.ROI = Rectangle.Empty;//去掉ROI
                                               //res(I)=img1(I)-img2(I) if mask(I)!=0
                    var resImage = image.Sub(image, mask);
                    mask._Not();//反转mask的值(255->0, 0->255)
                    image.Copy(resImage, mask);//在mask(I)!= 0的条件下,把image1的值拷贝到resImage中
                    imageBox2.Image = resImage;                
                }
            }
    

      

  • 相关阅读:
    JAVA代码覆盖率工具JaCoCo-原理篇
    (转载)比较web ui 框架
    sql拼接
    解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large问题
    字符串中重复出现字符串个数
    Unable to load annotation processor factory
    三目运算符
    WSGI剖析
    深入剖析cpp对象模型
    Cpp下匿名对象探究
  • 原文地址:https://www.cnblogs.com/xiaoxin121/p/6879115.html
Copyright © 2011-2022 走看看