c# opencvsharp学习笔记(4)操作像素点,椒盐噪声,重映射

这篇博客介绍了如何在C#中使用OpenCVSharp库进行像素点操作,包括读取像素点时的注意事项,以及如何处理椒盐噪声。此外,还详细讲解了图像的重映射过程,提供了一个简单的重映射示例。
摘要由CSDN通过智能技术生成


1.操作像素点

在这里和c++的区别就出来了,c++对像素点的setget用的是at函数。而c#的at函数只能用于get,set用的就是set函数,我一般直接用setget函数.

 //
        // 摘要:
        //     Set a value to the specified array element.
        //将值设置为指定的数组元素.。
        // 参数:
        //   i0:
        //     Index along the dimension 0
        //沿维度0的索引
        //   i1:
        //     Index along the dimension 1
        //沿维度1的索引
        //   value:
        //
        // 类型参数:
        //   T:
        public void Set<T>(int i0, int i1, T value) where T : struct;
        public void Set<T>(int i0, int i1, int i2, T value) where T : struct;
        public void Set<T>(int[] idx, T value) where T : struct;
        public void Set<T>(int i0, T value) where T : struct;

几种重载,看着有点迷糊。实际上

//来个复杂点的, 
for (int i = 0; i < panda.Rows; i++)//遍历所有像素点
            {
                for (int j = 0; j < panda.Cols; j++)
                {
                    pandax.Set(i, j, (float)j);//x不动,转成float是必须的,参数不一样重载的函数也不一样
                    // panday.Set(i, j, (float)(panda.Rows - i));//y上下对换
                    panday.Set(i, j, (float)(i + 5 * Math.Sin(j / 1.0)));//波浪
                }
            }


对于3通道彩色图像

 Vec3b black = new Vec3b(0, 0, 0);//3个char,对应BGR
 src.Set(i, j, black);//行,列,vec3b(opencv好奇葩,好多都反着来)
对于单通道灰色图像

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值