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