static void Main() { //load from the Web var image = new Uri("http://vignette3.wikia.nocookie.net/disney/images/5/5d/Lena_headey_.jpg") .GetBytes() .DecodeAsColorImage(); //show image image.Show("New Lena"); //to zoom or translate: press and hold Shift and scroll or move your mouse image = new Bgr <byte> [480, 640]; //draw something image.Draw(new Rectangle(50, 50, 200, 100), Bgr <byte> .Red, -1); image.Draw(new Circle(50, 50, 25), Bgr <byte> .Blue, 5); image.Draw(new Box2D(new Point(250, 150), new Size(100, 100), 30), Bgr <byte> .Green, 1); image.Draw("Hello world!", Font.Big, new Point(10, 100), Bgr <byte> .White); //save and load image.Save("out.png"); ImageIO.LoadColor("out.png").Clone().Show("Saved image", scaleForm: true); Console.WriteLine("Press [Enter] to exit."); Console.ReadLine(); UI.CloseAll(); }
unsafe static void Main() { var resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); var imgColor = ImageIO.LoadColor(Path.Combine(resourceDir, "testColorBig.jpg")).Clone(); var rImg = imgColor.AsEnumerable().Select(x => x.G).ToArray2D(imgColor.Width(), imgColor.Height()); }
static void Main() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced //load from the Web var image = new Uri("http://vignette3.wikia.nocookie.net/disney/images/5/5d/Lena_headey_.jpg") .GetBytes() .DecodeAsColorImage(); //show image image.Show("New Lena"); //to zoom or translate: press and hold Shift and scroll or move your mouse //draw something image.Draw(new Rectangle(50, 50, 200, 100), Bgr <byte> .Red, -1); image.Draw(new Circle(50, 50, 25), Bgr <byte> .Blue, 5); image.Draw(new Box2D(new Point(250, 150), new Size(100, 100), 30), Bgr <byte> .Green, 1); image.Draw("Hello world!", Font.Big, new Point(10, 100), Bgr <byte> .White); //save and load image.Save("out.png"); ImageIO.LoadColor("out.png").Clone().Show("Saved image", scaleForm: true); Console.WriteLine("Press [Enter] to exit."); Console.ReadLine(); UI.CloseAll(); }
unsafe static void Main() { var resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); var imgColor = ImageIO.LoadColor(Path.Combine(resourceDir, "testColorBig.jpg")).Clone(); //imgColor = imgColor.CorrectContrast(105); }
unsafe static void Main() { //test get-rectangle async var resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); var imgColor = ImageIO.LoadColor(Path.Combine(resourceDir, "testColorBig.jpg")).Clone(); int i = 0; while (true) { var im = imgColor.Clone <Bgr <byte> >(); im.Draw(i.ToString(), Font.Big, new Point(45, 45), Bgr <byte> .Red); im.GetRectangle(onDrawn: (rect) => Console.WriteLine(rect)); i++; } UI.CloseAll(); return; //test Menu var selectedIdx = UI.ShowMenu(itemNames: new string[] { "Option A", "Option B" }, actions: new Action[] { () => Console.WriteLine("Option A"), () => Console.WriteLine("Option B") }); Console.WriteLine("Selected option: {0}", selectedIdx); UI.CloseAll(); return; //test image encoding-decoding byte[] arr = imgColor.EncodeAsPng(); var decodedIm = arr.DecodeAsColorImage(); decodedIm.Save("out.bmp"); var rImg = imgColor.AsEnumerable().Select(x => x.G).ToArray2D(imgColor.Width(), imgColor.Height()); }
unsafe static void Main() { var resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); var imgColor = ImageIO.LoadColor(Path.Combine(resourceDir, "testColorBig.jpg")).Clone(); byte[] arr = imgColor.EncodeAsPng(); var decodedIm = arr.DecodeAsColorImage(); decodedIm.Save("out.bmp"); var rImg = imgColor.AsEnumerable().Select(x => x.G).ToArray2D(imgColor.Width(), imgColor.Height()); }
static void Main(string[] args) { var image = ImageIO.LoadColor("../Resources/pair.jpg").Clone(); /*../Resources/nature.jpg*/ image.Show("Original", scaleForm: true); var tic = DateTime.Now.Ticks; { image.Devignette(optimizeVignettingCentre: true); image.Show("Corrected", scaleForm: true); } var toc = DateTime.Now.Ticks; Console.WriteLine("Elapsed: {0} ms.", (toc - tic) / TimeSpan.TicksPerMillisecond); }
static void TestDrawingFunctions() { var resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); var imgColor = ImageIO.LoadColor(Path.Combine(resourceDir, "testColorBig.jpg")).Clone(); //imgColor.DrawAnnotation(new Rectangle(10, 10, 500, 500), "Some text.", Font.Big); //imgColor.Draw("Some text.", new Font(FontTypes.HERSHEY_PLAIN, 10, 10, 10), new Point(50, 50), Bgr<byte>.Red, 85); //imgColor.Draw(new Rectangle(10, 10, 500, 500), Bgr<byte>.Red, -1, 85); //imgColor.Draw(new Circle(500, 500, 250), Bgr<byte>.Blue, -1, 128); //imgColor.Draw(new Ellipse(new PointF(500, 500), new SizeF(200, 500), 45), Bgr<byte>.Green, 10, 25); //imgColor.Draw(new Box2D(new PointF(500, 500), new SizeF(200, 500), 45), Bgr<byte>.Green, 10, 255); imgColor.Draw(new Point[] { new Point(10, 10), new Point(500, 10), new Point(500, 600), new Point(25, 10) }, Bgr <byte> .Red, 10, 128); imgColor.Show(); }
public BasicImageOperationsDemo() { InitializeComponent(); //create a managed image var image = new Bgr <byte> [480, 640]; //draw something image.Draw(new Rectangle(50, 50, 200, 100), Bgr <byte> .Red, -1); image.Draw(new Circle(50, 50, 25), Bgr <byte> .Blue, 5); image.Draw(new Box2D(new Point(250, 150), new Size(100, 100), 30), Bgr <byte> .Green, 1); image.Draw("Hello world!", CvFont.Big, new Point(10, 100), Bgr <byte> .White); //save and load image.Save("out.png"); pictureBox.Image = ImageIO.LoadColor("out.png").ToBitmap(); }
static void Main() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced //load from the Web var image = new Uri("http://vignette3.wikia.nocookie.net/disney/images/5/5d/Lena_headey_.jpg") .GetBytes() .DecodeAsColorImage(); //show image image.Show("New Lena"); //draw something image.DrawRectangle(new Rectangle(50, 50, 200, 100), Bgr <byte> .Red, -1); image.DrawText("Hello world!", DotImaging.Font.Big, new Point(10, 100), Bgr <byte> .White); //save and load image.Save("out.png"); ImageIO.LoadColor("out.png").ShowDialog("Saved image", autoSize: true); }