示例#1
0
        public void ApplyChannelGains()
        {
            using (var src = Image("lenna.png"))
                using (var b = new Mat(src.Rows, src.Cols, src.Type()))
                    using (var g = new Mat(src.Rows, src.Cols, src.Type()))
                        using (var r = new Mat(src.Rows, src.Cols, src.Type()))
                        {
                            CvXPhoto.ApplyChannelGains(src, b, 2, 1, 1);
                            CvXPhoto.ApplyChannelGains(src, g, 1, 2, 1);
                            CvXPhoto.ApplyChannelGains(src, r, 1, 1, 2);

                            if (Debugger.IsAttached)
                            {
                                using (var combined = new Mat(src.Rows * 2, src.Cols * 2, src.Type()))
                                    using (var roi1 = new Mat(combined, new Rect(0, 0, src.Cols, src.Rows)))
                                        using (var roi2 = new Mat(combined, new Rect(src.Cols, 0, src.Cols, src.Rows)))
                                            using (var roi3 = new Mat(combined, new Rect(0, src.Rows, src.Cols, src.Rows)))
                                                using (var roi4 = new Mat(combined, new Rect(src.Cols, src.Rows, src.Cols, src.Rows)))
                                                {
                                                    src.CopyTo(roi1);
                                                    b.CopyTo(roi2);
                                                    g.CopyTo(roi3);
                                                    r.CopyTo(roi4);
                                                    Window.ShowImages(combined);
                                                }
                            }
                        }
        }
示例#2
0
 public void Inpaint()
 {
     using var src  = Image("building.jpg");
     using var mask = Image("building_mask.bmp", ImreadModes.Grayscale);
     using var dst  = new Mat(src.Size(), src.Type());
     CvXPhoto.Inpaint(src, mask, dst, InpaintTypes.SHIFTMAP);
     ShowImagesWhenDebugMode(src);
     ShowImagesWhenDebugMode(dst);
 }
示例#3
0
        public void OilPainting()
        {
            using var src = Image("lenna.png", ImreadModes.Grayscale);
            using var dst = new Mat();
            CvXPhoto.OilPainting(src, dst, 5, 10);

            if (Debugger.IsAttached)
            {
                Window.ShowImages(src, dst);
            }
        }
示例#4
0
        public void DctDenoising()
        {
            using var src = Image("lenna.png");
            using var dst = new Mat();
            CvXPhoto.DctDenoising(src, dst, 1);

            if (Debugger.IsAttached)
            {
                Window.ShowImages(src, dst);
            }
        }
示例#5
0
 public void Inpaint()
 {
     using (var src = Image("building.jpg"))
         using (var mask = Image("building_mask.bmp", ImreadModes.GrayScale))
             using (var dst = new Mat(src.Size(), src.Type()))
             {
                 CvXPhoto.Inpaint(src, mask, dst, InpaintTypes.ShiftMap);
                 ShowImagesWhenDebugMode(src);
                 ShowImagesWhenDebugMode(dst);
             }
 }
示例#6
0
        public void GrayworldWBProperties()
        {
            using var wb = CvXPhoto.CreateGrayworldWB();
            var saturationThreshold = wb.SaturationThreshold;

            const float val = 100f;

            wb.SaturationThreshold = val;

            Assert.Equal(val, wb.SaturationThreshold);
            Assert.NotEqual(saturationThreshold, wb.SaturationThreshold);
        }
示例#7
0
        public void Bm3dDenoising()
        {
            using (var src = Image("lenna.png", ImreadModes.Grayscale))
                using (var dst = new Mat())
                {
                    CvXPhoto.Bm3dDenoising(src, dst);

                    if (Debugger.IsAttached)
                    {
                        Window.ShowImages(src, dst);
                    }
                }
        }
示例#8
0
        public void LearningBasedWBBalanceWhite()
        {
            using var wb  = CvXPhoto.CreateLearningBasedWB(null);
            using var src = Image("lenna.png");
            using var dst = new Mat(src.Rows, src.Cols, src.Type());
            wb.BalanceWhite(src, dst);

            if (Debugger.IsAttached)
            {
                using var combined = new Mat(src.Rows, src.Cols * 2, src.Type());
                using var roi1     = new Mat(combined, new Rect(0, 0, src.Cols, src.Rows));
                using var roi2     = new Mat(combined, new Rect(src.Cols, 0, src.Cols, src.Rows));
                src.CopyTo(roi1);
                dst.CopyTo(roi2);
                Window.ShowImages(combined);
            }
        }
示例#9
0
        public void LearningBasedWBBalanceWhiteWithModel()
        {
            // About model file
            // http://docs.opencv.org/trunk/dc/dcb/tutorial_xphoto_training_white_balance.html
            using var wb  = CvXPhoto.CreateLearningBasedWB("");
            using var src = Image("lenna.png");
            using var dst = new Mat(src.Rows, src.Cols, src.Type());
            wb.BalanceWhite(src, dst);

            if (Debugger.IsAttached)
            {
                using var combined = new Mat(src.Rows, src.Cols * 2, src.Type());
                using var roi1     = new Mat(combined, new Rect(0, 0, src.Cols, src.Rows));
                using var roi2     = new Mat(combined, new Rect(src.Cols, 0, src.Cols, src.Rows));
                src.CopyTo(roi1);
                dst.CopyTo(roi2);
                Window.ShowImages(combined);
            }
        }
示例#10
0
        public void GrayworldWBBalanceWhite()
        {
            using (var wb = CvXPhoto.CreateGrayworldWB())
                using (var src = Image("lenna.png"))
                    using (var dst = new Mat(src.Rows, src.Cols, src.Type()))
                    {
                        wb.BalanceWhite(src, dst);

                        if (Debugger.IsAttached)
                        {
                            using (var combined = new Mat(src.Rows, src.Cols * 2, src.Type()))
                                using (var roi1 = new Mat(combined, new Rect(0, 0, src.Cols, src.Rows)))
                                    using (var roi2 = new Mat(combined, new Rect(src.Cols, 0, src.Cols, src.Rows)))
                                    {
                                        src.CopyTo(roi1);
                                        dst.CopyTo(roi2);
                                        Window.ShowImages(combined);
                                    }
                        }
                    }
        }