示例#1
0
        public static Mat Extract(Mat srcMat, ColorConversionCodes code, ColorVariation color)
        {
            //            int a = Enum.GetNames(typeof(ColorConversion)).Length;
            ColorTable table;
            if (code == ColorConversionCodes.BGR2HSV)
            {
                switch (color)
                {
                    //                    case ColorVariation.Black:
                    //                        table = new ColorTable(0, 0, 0, 0, 0, 0);
                    //                        break;
                    //                    case ColorVariation.DarkRed:
                    //                        table = new ColorTable(0, 0, 0, 0, 0, 0);
                    //                        break;
                    case ColorVariation.Green:
                        table = new ColorTable(50, 70, 80, 255, 0, 255);
                        break;
                    //                    case ColorVariation.Orange:
                    //                        table = new ColorTable(0, 0, 0, 0, 0, 0);
                    //                        break;
                    case ColorVariation.Red:
                        table = new ColorTable(170, 10, 80, 255, 0, 255);
                        break;
                    case ColorVariation.Skin:
                        table = new ColorTable(0, 10, 80, 255, 0, 255);
                        break;
                    //                    case ColorVariation.White:
                    //                        table = new ColorTable(0, 0, 0, 0, 0, 0);
                    //                        break;
                    default:
                        table = new ColorTable(0, 0, 0, 0, 0, 0);
                        break;
                }

                return Extract(
                    srcMat,
                    code,
                    table.ch1Lower, table.ch1Upper,
                    table.ch2Lower, table.ch2Upper,
                    table.ch3Lower, table.ch3Upper
                    );
            }
            else
            {
                throw new NotImplementedException("HSV 値以外を用いた抽出は実装されていません");
            }
        }
示例#2
0
        public static Mat ExtractRegularFormat(Mat srcMat, ColorConversionCodes code,
        ColorTable table)
        {
            /*
            Console.WriteLine("{0} : {1} : {2} : {3} : {4} : {5}",
                ch1LowerAngle / 2,
                ch1UpperAngle / 2,
                ch2LowerPer * 255 / 100,
                ch2UpperPer * 255 / 100,
                ch3LowerPer * 255 / 100,
                ch3UpperPer * 255 / 100);*/

            return ExtractRegularFormat(
                srcMat,
                code,
                table.ch1Lower, table.ch1Upper,
                table.ch2Lower, table.ch2Upper,
                table.ch3Lower, table.ch3Upper
                );
        }
示例#3
0
 public static Mat ExtractMask(Mat srcMat, ColorConversionCodes code, ColorTable table)
 {
     return ExtractMask(
         srcMat,
         code,
         table.ch1Lower, table.ch1Upper,
         table.ch2Lower, table.ch2Upper,
         table.ch3Lower, table.ch3Upper
         );
 }