一、API
1、 AT();
public T At<T>(int i0, int i1) where T : struct; //返回指定数组元素的值。
public T At<T>(int i0) where T : struct;
public T At<T>(params int[] idx) where T : struct;
public T At<T>(int i0, int i1, int i2) where T : struct;
- 参数说明
i0: Index along the dimension 0 (沿着空间维度0索引)
i1: Index along the dimension 1 (沿着空间维度1索引)
2、Get()
3、Set()
二、单通道图像像素处理
private void uiButton9_Click(object sender, EventArgs e)
{
//1:转为灰度图像
Mat m2 = new Mat();
Mat gray = new Mat();
Cv2.CvtColor(src_img, m2, ColorConversionCodes.BGR2GRAY);
m2.CopyTo(gray);
int height = m2.Rows; //行 获取图片的行叠加起来就是高度
int width = m2.Cols; //列 ... ... 宽度
//单通道像素反转
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
byte p = m2.At<byte>(row, col); //获对应矩阵坐标的取像素
byte value = byte.Parse((255 - p).ToString()); //反转像素值
m2.Set(row, col, value); //赋值
}
}
picBoxShowDel.Image = gray.ToBitmap();
pictureBox1.Image = m2.ToBitmap();
}
}
- 反转像素API
Cv2.BitwiseNot(src, dst);
反转像素函数,不需要操作像素,达到的效果一样
- ~ 取反符号:输出同样效果
using (new Window("dst", WindowMode.FreeRatio, ~src))
反转
网友评论