示例#1
0
        static public bool GetLoadLUTFiles(SapLut pLut, ArrayList FileSave_list)
        {
            //////// Ask questions to user to select LUT file ////////
            string fileName = "";

            Console.WriteLine("\nDo you want to load an existing LUT file? y/n (Yes/No)  \n");
            ConsoleKeyInfo keyQuestion = Console.ReadKey(true);
            char           key         = keyQuestion.KeyChar;

            if (key == 'n')
            {
                return(false);
            }
            else if (key == 'y')
            {
                Console.WriteLine("\nSelect the LUT file available: \n");
                GetLUTFilesSaved(".", FileSave_list);
                if (FileSave_list.Count != 0)
                {
                    keyQuestion = Console.ReadKey(true);
                    key         = keyQuestion.KeyChar;

                    int fileNum = key - '0';
                    if ((fileNum >= 1) && (fileNum <= FileSave_list.Count))
                    {
                        fileName = (string)FileSave_list[fileNum - 1];
                        // Load LUT (saved before in the main demo)
                        if (pLut.Load(fileName))
                        {
                            Console.WriteLine("\n................");
                            Console.WriteLine(fileName + " loaded.");
                            Console.WriteLine("..................\n");
                            return(true);
                        }
                    }
                    else
                    {
                        Console.WriteLine("\nInvalid selection!\n");
                        return(false);
                    }
                }
                else
                {
                    Console.WriteLine("\nInvalid selection!\n");
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("\nNo Lut File Avaible. Please load an existing one\n");
                return(false);
            }
            return(false);
        }
示例#2
0
        static public string GetLUTOptionsFromQuestions(SapBuffer pBuffers, SapLut pLut)
        {
            //////// Ask questions to user to select LUT mode ////////
            UInt32 prmIndex       = 1;
            string acqLutFileName = "";
            string chAcqLutName   = "";

            while (string.IsNullOrEmpty(chAcqLutName))
            {
                Console.WriteLine("\nSelect the LookUpTable mode you want to apply: \n");

                Console.WriteLine("a : Normal mode");
                Console.WriteLine("b : Arithmetic mode");
                Console.WriteLine("c : Binary mode");
                Console.WriteLine("d : Boolean mode");
                Console.WriteLine("e : Gamma mode");
                Console.WriteLine("f : Reverse mode");
                Console.WriteLine("g : Roll mode");
                Console.WriteLine("h : Shift mode");
                Console.WriteLine("i : Slope mode");
                Console.WriteLine("j : Threshold single mode");
                Console.WriteLine("k : Threshold double mode");

                ConsoleKeyInfo info = Console.ReadKey(true);
                char           key  = info.KeyChar;
                switch (key)
                {
                case 'a':
                {
                    pLut.Normal();
                    acqLutFileName = "Normal_Lut_Mode.lut";
                    chAcqLutName   = "Normal Lut";
                    break;
                }

                case 'b':
                {
                    int operationMode = 0;                //Linear plus offset with clip

                    /*
                     *      Others operations available
                     */
                    //int operation = 1;//Linear minus offset(absolute)
                    //int operation = 2;//Linear minus offset(with clip)
                    //int operation = 3;//Linear with lower clip
                    //int operation = 4;//Linear with upper clip
                    //int operation = 5;//Scale to maximum limit

                    SapData offSet;
                    offSet = SetDataValue(pBuffers, prmIndex);
                    pLut.Arithmetic((SapLut.ArithmeticOp)operationMode, offSet);
                    acqLutFileName = "Arithmetic_Lut_Mode.lut";
                    chAcqLutName   = "Arithmetic Lut";
                    break;
                }

                case 'c':
                {
                    SapData clipValue;
                    clipValue = SetDataValue(pBuffers, prmIndex);
                    pLut.BinaryPattern(0, clipValue);
                    acqLutFileName = "Binary_Lut_Mode.lut";
                    chAcqLutName   = "Binary Lut";
                    break;
                }

                case 'd':
                {
                    SapData booleanFunction;
                    booleanFunction = SetDataValue(pBuffers, prmIndex);
                    pLut.Boolean((SapLut.BooleanOp) 0, booleanFunction);

                    /*
                     *      Others operations available
                     */
                    // AND
                    //pLut->Boolean((SapLut::BooleanOp)1, booleanFunction);
                    // OR
                    //pLut->Boolean((SapLut::BooleanOp)2, booleanFunction);
                    // XOR
                    acqLutFileName = "Boolean_Lut_Mode.lut";
                    chAcqLutName   = "Boolean Lut";
                    break;
                }

                case 'e':
                {
                    int gammaFactor = (int)(2 * GAMMA_FACTOR);
                    pLut.Gamma((float)gammaFactor / GAMMA_FACTOR);
                    acqLutFileName = "Gamma_Lut_Mode.lut";
                    chAcqLutName   = "Gamma Lut";
                    break;
                }

                case 'f':
                {
                    pLut.Reverse();
                    acqLutFileName = "Reverse_Lut_Mode.lut";
                    chAcqLutName   = "Reverse Lut";
                    break;
                }

                case 'g':
                {
                    int numEntries = 128;
                    pLut.Roll(numEntries);
                    acqLutFileName = "Roll_Lut_Mode.lut";
                    chAcqLutName   = "Roll Lut";
                    break;
                }

                case 'h':
                {
                    int bitsToShift = 3;
                    pLut.Shift(bitsToShift);
                    acqLutFileName = "Shift_Lut_Mode.lut";
                    chAcqLutName   = "Shift Lut";
                    break;
                }

                case 'i':
                {
                    int     startIndex1 = 76;
                    int     endIndex1   = 179;
                    bool    clipOutSide = false;             //TRUE
                    SapData minValue;
                    SapData maxValue;
                    minValue = SetDataValue(pBuffers, prmIndex);
                    maxValue = SetDataValue(pBuffers, prmIndex);
                    pLut.Slope(startIndex1, endIndex1, minValue, maxValue, clipOutSide);
                    acqLutFileName = "Slope_With_Range_Lut_Mode.lut";
                    chAcqLutName   = "Slope With Range Lut";
                    break;
                }

                case 'j':
                {
                    SapData treshValue;
                    treshValue = SetDataValue(pBuffers, prmIndex);
                    pLut.Threshold(treshValue);
                    acqLutFileName = "Threshold_Single_Mode.lut";
                    chAcqLutName   = "Threshold Single Lut";
                    break;
                }

                case 'k':
                {
                    SapData treshValue1;
                    SapData treshValue2;
                    treshValue1 = SetDataValue(pBuffers, prmIndex);
                    treshValue2 = SetDataValue(pBuffers, prmIndex);
                    pLut.Threshold(treshValue1, treshValue2);
                    acqLutFileName = "Threshold_Double_Mode.lut";
                    chAcqLutName   = "Threshold Double Lut";
                    break;
                }

                default:
                {
                    Console.WriteLine("\nInvalid selection!\n");
                    break;
                }
                }
            }
            pLut.Save(acqLutFileName);                  // Save LUT to file (can be reloaded in the main demo)
            Console.WriteLine("\n");
            return(chAcqLutName);
        }