Пример #1
0
        public void SimpleWBProperties()
        {
            using var wb = SimpleWB.Create();
            var inputMax  = wb.InputMax;
            var inputMin  = wb.InputMin;
            var outputMax = wb.OutputMax;
            var outputMin = wb.OutputMin;
            var p         = wb.P;

            const float val = 100f;

            wb.InputMax  = val;
            wb.InputMin  = val;
            wb.OutputMax = val;
            wb.OutputMin = val;
            wb.P         = val;

            Assert.Equal(val, wb.InputMax);
            Assert.Equal(val, wb.InputMin);
            Assert.Equal(val, wb.OutputMax);
            Assert.Equal(val, wb.OutputMin);
            Assert.Equal(val, wb.P);

            Assert.NotEqual(inputMax, wb.InputMax);
            Assert.NotEqual(inputMin, wb.InputMin);
            Assert.NotEqual(outputMax, wb.OutputMax);
            Assert.NotEqual(outputMin, wb.OutputMin);
            Assert.NotEqual(p, wb.P);
        }
Пример #2
0
        public void Sample()
        {
            if (!Debugger.IsAttached)
            {
                return;
            }

            string[] files;
            using (var dialog = new System.Windows.Forms.OpenFileDialog
            {
                RestoreDirectory = true,
                Multiselect = true,
                Filter = "Image Files(*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp"
            })
            {
                if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                files = dialog.FileNames;
            }

            var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var dstDir  = System.IO.Path.Combine(desktop, "WB");

            System.IO.Directory.CreateDirectory(dstDir);

            using var simpleWB    = SimpleWB.Create();
            using var learningWB  = LearningBasedWB.Create("");
            using var grayworldWB = GrayworldWB.Create();

            foreach (var file in files)
            {
                testOutputHelper.WriteLine(System.IO.Path.GetFileNameWithoutExtension(file));

                using var src          = new Mat(file);
                using var dstSimple    = new Mat();
                using var dstLearning  = new Mat();
                using var dstGrayworld = new Mat();
                simpleWB.BalanceWhite(src, dstSimple);
                learningWB.BalanceWhite(src, dstLearning);
                grayworldWB.BalanceWhite(src, dstGrayworld);

                using var temp1 = new Mat();
                using var temp2 = new Mat();
                using var dst   = new Mat();
                Cv2.HConcat(src, dstSimple, temp1);
                Cv2.HConcat(dstLearning, dstGrayworld, temp2);
                Cv2.VConcat(temp1, temp2, dst);

                /*
                 * using (new Window("src", src))
                 * using (new Window("dst", dst))
                 * {
                 *  Cv2.WaitKey();
                 * }*/
                dst.SaveImage(System.IO.Path.Combine(dstDir, $"{System.IO.Path.GetFileNameWithoutExtension(file)}.png"));
            }
        }