C#+emgucv学习过程记录之图像

开始学习C#+emgucv了,这里会有一些自己想要记住的东西!!开始更新!!

图像

1、创建图像

Image<Gray(颜色属性), Byte(图像深度)> image = new Image<Gray, Byte>( width, height);

其中颜色属性可选:

  • Gray
  • Bgr (Blue Green Red)
  • Bgra (Blue Green Red Alpha)
  • Hsv (Hue Saturation Value)
  • Hls (Hue Lightness Saturation)
  • Lab (CIE L*a*b*)
  • Luv (CIE L*u*v*)
  • Xyz (CIE XYZ.Rec 709 with D65 white point)
  • Ycc (YCrCb JPEG)
其中图像深度可选:

  • Byte
  • SByte
  • Single (float)
  • Double
  • UInt16
  • Int16
  • Int32 (int)
创建一个480 x320 Bgr的色彩和8位无符号的深度的图像。在c#代码表示为:

Image<Bgr, Byte> img1 = new Image<Bgr, Byte>(480, 320);
如果想创建指明为蓝色背景的图像,则

 Image<Bgr, Byte> img1 = new Image<Bgr, Byte>(480, 320, new Bgr(255, 0, 0));

2、从文件夹读取图像
如果想从某文件夹读取文件,则可用:
Image<Bgr, Byte> img1 = new Image<Bgr, Byte>("D:\MyImage.jpg");

3、创建位图
Image<Bgr, Byte> img = new Image<Bgr, Byte>(bmp);

4、获得像素颜色及设置像素颜色
慢一点的方法

Bgr color = img[y, x];
img[y,x] = color;
快一点的方法是如果有一个数组存了颜色信息则可以直接用。

5、命名规则
Image<TColorTDepth>.Not()就如OpenCv里面的cvNot一样,这是要返回值的。
Image<TColorTDepth>._Not()则不是返回一个值。

6、图像运算
这样的运算是合法的:
Image image3 = (image1 + image2 - 2.0) * 0.5;







你可能感兴趣的:(C#)