static void Main(string[] args) { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced //select color Bgr <byte>[,] image = new Bgr <byte> [480, 640]; Hsv <byte> color = UI.PickColor(Bgr <byte> .Red).ToHsv(); //select mask Gray <byte>[,] mask = image.GetMask(); if (mask.AsEnumerable().Sum(x => x.Intensity) == 0) //if the mask is empty { mask.SetValue <Gray <byte> >(Byte.MaxValue); } //increase saturation incrementally for (int s = 0; s <= Byte.MaxValue; s++) { color.S = (byte)s; image.SetValue <Bgr <byte> >(color.ToBgr(), mask); image.Show(scaleForm: true); ((double)s / Byte.MaxValue).Progress(message: "Changing saturation"); Thread.Sleep(50); } //save last image string fileName = UI.SaveImage(); if (fileName != null) { image.Save(fileName); } //close all UI.CloseAll(); }
static void Main(string[] args) { //select color Bgr <byte>[,] image = new Bgr <byte> [480, 640]; Hsv <byte> color = UI.PickColor(Bgr <byte> .Red).ToHsv(); //select mask Gray <byte>[,] mask = image.GetMask(); if (mask.AsEnumerable().Sum(x => x.Intensity) == 0) //if the mask is empty { mask.SetValue <Gray <byte> >(Byte.MaxValue); } //increase saturation incrementally for (int s = 0; s <= Byte.MaxValue; s++) { color.S = (byte)s; image.SetValue <Bgr <byte> >(color.ToBgr(), mask); image.Show(scaleForm: true); ((double)s / Byte.MaxValue).Progress(message: "Changing saturation"); Thread.Sleep(50); } //save last image string fileName = UI.SaveImage(); if (fileName != null) { image.Save(fileName); } //close all UI.CloseAll(); }