天天看點

Emgucv FloodFill 在c#調用方法,把預設黑底圖變白色

有點煩,必須經過複雜的步驟才能把一個黑色底圖變白色. 記錄一下

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);
        }
           

繼續閱讀