有点烦,必须经过复杂的步骤才能把一个黑色底图变白色. 记录一下
Image<Bgr, Byte> img1 = new Image<Bgr, Byte>(300, 320);
// Mask的长宽 +2, 且必须是Gray的.
Image<Gray, Byte> imgMask = new Image<Gray, Byte>(302, 322);
MCvScalar clrW = clsClr.whitem;
Rectangle rc = new Rectangle( 0, 0, 0,0);
CvInvoke.FloodFill(img1,imgMask, new Point(10, 10), clrW,out rc, clsClr.blackm,clsClr.whitem );
前面有个颜色的定义
public static class clsClr
{
public static Bgr blue = new Bgr(255, 0, 0);
public static MCvScalar bluem = new MCvScalar(255, 0, 0);
public static Bgr green = new Bgr(0,255, 0);
public static MCvScalar greenm = new MCvScalar(0, 255, 0);
public static Bgr red = new Bgr(0,0,255);
public static MCvScalar redm = new MCvScalar(0, 0, 255);
public static Bgr white = new Bgr(255,255,255);
public static MCvScalar whitem = new MCvScalar(255, 255, 255);
public static Bgr black = new Bgr(0, 0, 0);
public static MCvScalar blackm = new MCvScalar(0, 0, 0);
}