转:http://blog.sciencenet.cn/blog-538909-694431.html
mage<Bgr, Byte> frame =
capture.QueryFrame();//获取摄像头的视频帧
Image<Bgr, Byte> frame2 =
frame.Convert<Bgr, Byte>(); //将帧转换为RGB类型,对应为三维数组
Image<Gray,
Byte> grayFrame = frame.Convert<Gray,
Byte>();//将帧转换为Gray类型,对应为一维数组
Image<Ycc, Byte> currentYCrCbFrame =
frame.Convert<Ycc, Byte>();//将帧转换为YCbCr类型,对应为三维数组
Image<Gray,
Byte> skin = new Image<Gray, Byte>(frame.Width,
frame.Height);//构建灰度区域对象
int rows = frame.Rows;
int cols = frame.Cols;
Byte[, ,] bgrData=
frame2.Data;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
{
b =
bgrData[i, j, 0];
g = bgrData[i, j, 1];
r = bgrData[i, j,
2];
if (b < 110)
{
bgrData[i, j, 0] =
(byte)0;
bgrData[i, j, 1] = (byte)0;
bgrData[i, j, 2] = (byte)0;
}
else
//二值化
{
bgrData[i, j, 0] = (byte)255;
bgrData[i, j, 1] = (byte)255;
bgrData[i, j, 2] =
(byte)255;
}
}
pictureBox1.Image = frame2.Flip(Emgu.CV.CvEnum.FLIP.NONE).ToBitmap();
//转换后,在picture上显示二值化图像。
C#-Emgu.CV-------视频截取和图像处理基础,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/mmcmmc/p/3731166.html