コード例 #1
0
        static void Main(string[] args)
        {
            // create bitmap from file and convert it to Image<Pixel32>
            var inputImagePath = @"inputImage.bmp";
            var bitmap         = new Bitmap(inputImagePath);
            var image          = ImageProcessingLibConverter.CreateImageFromBitmap(bitmap);

            // resize it to desired size
            image.Resize(512, 512, ResizeMethod.BilinearInterpolation);

            // rotate it and flip horizontally
            image.RotationClockwise()
            .FlipHorizontal();

            // get image histogram
            var histogram = image.Histogram();

            // calculate discrete Fourier transform
            var dft = image.DFT();

            // create binary image
            var binaryImage = image.CopyAs(p => p.ToPixel1());

            // perform closing and skeletonization operations
            binaryImage.Closing(3)
            .Skeletonization();

            // return to Image<Pixel32>, create Bitmap from it and save it
            var resultImage     = binaryImage.CopyAs(p => p.ToPixel32());
            var resultBitmap    = ImageProcessingLibConverter.CreateBitmapFromImage(resultImage);
            var outputImagePath = @"outputImage.bmp";

            resultBitmap.Save(outputImagePath);
        }
コード例 #2
0
        private void miLoad_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            ofd.Filter           = "Bitmap images (.bmp)|*.bmp";

            var result = ofd.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    bitmap.Dispose();
                    bitmap = new Bitmap(ofd.FileName);
                    var image        = ImageProcessingLibConverter.CreateImageFromBitmap(bitmap);
                    var targetBitmap = ImageProcessingLibConverter.CreateBitmapFromImage(image);
                    pbImage.Image = targetBitmap;
                    MessageBox.Show("Image loaded", "Information");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Can not load file: " + exc.Message, "Exception");
                }
            }
        }
コード例 #3
0
        static void Main()
        {
            var bmp    = ImagesFolder.Images.Lena;
            var image  = ImageProcessingLibConverter.CreateImageFromBitmap(bmp);
            var result = ImageProcessingLibConverter.CreateBitmapFromImage(image);

            Run(result);
        }
コード例 #4
0
        private void LoadResults(Bitmap bitmap, IComparison comparison)
        {
            try
            {
                DisposeImages();

                var originalBitmap = bitmap;
                var originalImage  = ImageProcessingLibConverter.CreateImageFromBitmap(originalBitmap);

                Bitmap tempResult = null;
                var    fipTime    = ExecTime.Run(() =>
                {
                    tempResult = comparison.GetFIPResults(new FIP.FIP(), originalBitmap);
                });
                var fipBitmap = (Bitmap)tempResult.Clone();
                var fipImage  = ImageProcessingLibConverter.CreateImageFromBitmap(fipBitmap);

                Image <Pixel32> iplImage = null;
                var             iplTime  = ExecTime.Run(() =>
                {
                    iplImage = comparison.GetIPLResult(originalImage);
                });
                var iplBitmap = ImageProcessingLibConverter.CreateBitmapFromImage(iplImage);

                ThreadSafeInvoke.Invoke(this, () =>
                {
                    pbFIP.Image = fipBitmap;
                    pbIPL.Image = iplBitmap;

                    tsslInfo.Text = string.Format("MSE: {0:0.00}, IPL: {1:0}ms, FIP: {2:0}ms",
                                                  GetMetrics(fipImage, iplImage),
                                                  iplTime.TotalMilliseconds, fipTime.TotalMilliseconds);
                });

                createdBitmaps = new List <Bitmap>()
                {
                    fipBitmap, iplBitmap
                };
            }
            catch (Exception e)
            {
                MessageBoxEx.ShowException(e);
            }
        }
コード例 #5
0
        private void LoadFile()
        {
            var filePath = dialogService.OpenFile();

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            try
            {
                var bitmap       = CreateBitmapSourceFromFile(filePath);
                var image        = ImageProcessingLibConverter.CreateImageFromBitmap(bitmap);
                var targetBitmap = ImageProcessingLibConverter.CreateBitmapFromImage(image);
                Image = targetBitmap;
                dialogService.ShowInformation("Image loaded");
            }
            catch (Exception e)
            {
                dialogService.ShowException(e, "Can not load file: ");
            }
        }
コード例 #6
0
 public ImageWrapper(Bitmap bitmap)
 {
     Bitmap = bitmap;
     Image  = ImageProcessingLibConverter.CreateImageFromBitmap(bitmap);
 }