コード例 #1
0
        public PageSelect()
        {
            InitializeComponent();

            this.Zoom           = 1.0;
            viewBox.DataContext = this;

            CommandBinding cb = new CommandBinding(ApplicationCommands.Open);

            cb.Executed += new ExecutedRoutedEventHandler(cb_Executed);
            this.CommandBindings.Add(cb);

            CommandBinding cb1 = new CommandBinding(NavigationCommands.Zoom);

            cb1.Executed += new ExecutedRoutedEventHandler(cb1_Executed);
            this.CommandBindings.Add(cb1);

            ImageF image = ImageF.RandomPixelImage(10, 10, 1);

            Psf     = PSF.SymmetricGaussian(0.5);
            Picture = new ImageFWrapper(image);

            theImage.Source = Picture.Bitmap;
            viewBox.Width   = theImage.Width;
            viewBox.Height  = theImage.Height;
        }
コード例 #2
0
    /// <summary>
    /// Resize and crop an image to fill a mask of specified width and height
    /// </summary>
    /// <param name="width">Mask width</param>
    /// <param name="height">Mask height</param>
    /// <param name="apply">Function to perform the graphics manipulation</param>
    protected Maybe <IImageWrapper> ApplyMask(int width, int height, Func <Size, Rectangle, IImageWrapper> apply)
    {
        // At least one of width and height should be greater than zero
        if (width == 0 && height == 0)
        {
            return(F.None <IImageWrapper, M.MaskHeightOrWidthRequiredMsg>());
        }

        // Calculate the size of the new image
        var size = ImageF.CalculateNewSize(Width, Height, width, height);

        // Calculate the mask to apply to the original image
        var mask = ImageF.CalculateMask(Width, Height, size.Width, size.Height);

        // Use implementation to return masked and resized image
        try
        {
            var resized = apply(size, mask);
            return(F.Some(resized));
        }
        catch (Exception e)
        {
            return(F.None <IImageWrapper>(new M.ApplyingImageMaskExceptionMsg(e)));
        }
    }
コード例 #3
0
    protected virtual void Dispose(bool disposing)
    {
        if (disposing)
        {
            ImageF.Dispose();
        }

        Url = null;
        // Cleanup
    }
コード例 #4
0
        void cb_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() == true)
            {
                Picture = new ImageFWrapper(ImageF.FromFile(dlg.FileName));

                theImage.Source = Picture.Bitmap;
                viewBox.Width   = theImage.Width;
                viewBox.Height  = theImage.Height;
            }
        }
コード例 #5
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "PhotoData|*.pds";
            dlg.DefaultExt = "pds";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                photograph = PhotographData.Load(dlg.FileName);

                iImage = Bitmap.FromFile(photograph.Image);
                iImageF = ImageF.FromBitmap(iImage as Bitmap);
                this.pictureMain.Size = iImage.Size;
                pictureMain.Image = iImage;

                foreach (SpatiallyVariantPsf thePsf in photograph.PSFs)
                {
                    this.imageScan1.Add(thePsf);
                }
            }
        }
コード例 #6
0
 static BitmapSource ToBitmap(ImageF image)
 {
     System.Drawing.Color[,] color = image.ToRawImage();
     return(ToBitmap(color));
 }
コード例 #7
0
ファイル: PSF.cs プロジェクト: JoostZ/astro-deconvolution
 private void CheckSize(ImageF image)
 {
     if (Convolver == null || FftSize.Width != image.Width || FftSize.Height != image.Height)
     {
         FftSize = new Size(image.Width, image.Height);
         double[,] imgData = new double[FftSize.Width, FftSize.Height];
         for (int x = 0; x < FftSize.Width; x++)
         {
             for (int y = 0; y < FftSize.Height; y++)
             {
                 imgData[x, y] = this[x + Xmin, y + Ymin];
             }
         }
         Convolver = new FftwConvolver.FftwConvolver(FftSize, imgData, new Point(-Xmin, -Ymin));
     }
 }
コード例 #8
0
ファイル: PSF.cs プロジェクト: JoostZ/astro-deconvolution
 public ImageF ConvoluteTranspose(ImageF image)
 {
     CheckSize(image);
     return ImageF.FromArray(Convolver.Convolve(image.ToRawData));
 }
コード例 #9
0
 static BitmapSource ToBitmap(ImageF image)
 {
     System.Drawing.Color[,] color = image.ToRawImage();
     return ToBitmap(color);
 }
コード例 #10
0
 /**
  * @brief
  * Constructor
  *
  * @param image
  * The image
  * @param psf
  * The %PSF to de-convolve
  *
  * Note that it is not important to know about the %PSF, just that
  * it is an object that can convolve itself withan image
  */
 public RichardsonLucyDeconvolution(ImageF image, IConvolutable psf)
 {
     Image = image;
     Psf = psf;
     Sn = ImageF.ConstantImage(image.Width, image.Height, 0.5);
 }
コード例 #11
0
 public ScanLineAnalyzer(ImageF image)
 {
     Image = image;
 }
コード例 #12
0
 public ScanLineAnalyzer(ImageF image, int scanLine)
 {
     Image = image;
     ScanLine = scanLine;
 }
コード例 #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="image"></param>
 /// <param name="scanLine"></param>
 /// <param name="xCenter"></param>
 public ScanLineAnalyzer(ImageF image, int scanLine, int xCenter)
 {
     Image = image;
     ScanLine = scanLine;
     XCenter = xCenter;
 }
コード例 #14
0
 public ImageF ConvoluteTranspose(ImageF image)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
 public ImageFWrapper(ImageF image)
 {
     Image = image;
 }
コード例 #16
0
ファイル: PSF.cs プロジェクト: JoostZ/astro-deconvolution
        public static unsafe PSF FromBitmap(ImageF image, Point pos)
        {
            PSF thePsf = new PSF();

            ScanLineAnalyzer analyzer = new ScanLineAnalyzer(image, pos.Y, pos.X);
            analyzer.FindBackground();

            thePsf._xmin = analyzer.LeftBackgroundPosition;
            thePsf._xmax = analyzer.RightBackgroundPosition;

            List<double> row = new List<double>();
            for (int x = analyzer.LeftBackgroundPosition; x <= analyzer.RightBackgroundPosition; x++)
            {
                row.Add(image[x, pos.Y]);
            }
            thePsf.iData[0] = row;
            do {
                analyzer.ScanLine--;
                analyzer.Analyze();
                if (analyzer.LeftBackgroundPosition < thePsf.Xmin)
                {
                    thePsf.Xmin = analyzer.LeftBackgroundPosition;
                }
                if (analyzer.RightBackgroundPosition > thePsf.Xmax) {
                    thePsf.Xmax = analyzer.RightBackgroundPosition;
                }

                row = new List<double>();
                for (int x = thePsf.Xmin; x <= thePsf.Xmax; x++)
                {
                    if (x < analyzer.LeftBackgroundPosition || x > analyzer.RightBackgroundPosition)
                    {
                        row.Add(0.0);
                    }
                    else {
                        row.Add(image[x, (int)analyzer.ScanLine]);
                    }
                }
                thePsf.iData.Insert(0, row);
                thePsf._ymin = (int)analyzer.ScanLine;
            } while(!analyzer.IsBackgroundLine);

            analyzer.ScanLine = pos.Y;
            do
            {
                analyzer.ScanLine++;
                analyzer.Analyze();
                if (analyzer.LeftBackgroundPosition < thePsf.Xmin)
                {
                    thePsf.Xmin = analyzer.LeftBackgroundPosition;
                }
                if (analyzer.RightBackgroundPosition > thePsf.Xmax)
                {
                    thePsf.Xmax = analyzer.RightBackgroundPosition;
                }

                row = new List<double>();
                for (int x = thePsf.Xmin; x <= thePsf.Xmax; x++)
                {
                    if (x < analyzer.LeftBackgroundPosition || x > analyzer.RightBackgroundPosition)
                    {
                        row.Add(0.0);
                    }
                    else
                    {
                        row.Add(image[x, (int)analyzer.ScanLine]);
                    }
                }
                thePsf.iData.Add(row);
                thePsf._ymax = (int)analyzer.ScanLine;
            } while (!analyzer.IsBackgroundLine);

            thePsf.Normalize();

            return thePsf;
        }
コード例 #17
0
 private void menuFileOpen_Click(object sender, EventArgs e)
 {
     if (this.openFileDialog.ShowDialog() == DialogResult.OK)
     {
         String theFile = openFileDialog.FileName;
         photograph = new PhotographData(theFile);
         iImage = Bitmap.FromFile(theFile);
         iImageF = ImageF.FromBitmap(iImage as Bitmap);
         this.pictureMain.Size = iImage.Size;
         pictureMain.Image = iImage;
         //this.AutoScrollMinSize = new Size(iImage.Width, iImage.Height);
     }
 }
コード例 #18
0
 public ImageFWrapper(ImageF image)
 {
     Image = image;
 }