public PageDeconvolve(ImageFWrapper image, PSF psf) : this() { BaseImage = image; Rc = new RichardsonLucyDeconvolution(image.Image, psf); ResultImage = new ImageFWrapper(Rc.Sn); }
//private void panelMain_Paint(object sender, PaintEventArgs e) //{ // if (iImage != null) // { // panelMain.AutoScroll = true; // using (Graphics gfx = panelMain.CreateGraphics()) // { // gfx.DrawImage(iImage, // AutoScrollPosition.X, // AutoScrollPosition.Y, // iImage.Width, // iImage.Height); // } // } //} private void pictureMain_MouseUp(object sender, MouseEventArgs e) { if (iImage != null && InPanel) { Point pos = e.Location; //pos.X -= panelImage.AutoScrollPosition.X; //pos.Y -= panelImage.AutoScrollPosition.Y; PSF thePsf = PSF.FromBitmap(iImageF, pos); SpatiallyVariantPsf wrapper = new SpatiallyVariantPsf(thePsf, pos); this.imageScan1.Add(wrapper); photograph.AddPsf(wrapper); picPreviewPsf.Image = thePsf.Bitmap; } }
/** * Constructor * * @param aPsf * The PSF * * @param aPosition * The position of the PSF in the underlying picture */ public SpatiallyVariantPsf(PSF aPsf, Point aPosition) { Psf = aPsf; Position = aPosition; }
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; }
unsafe static public 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); }
private void viewBox_MouseDown(object sender, MouseButtonEventArgs e) { Point pos = e.GetPosition(theImage); Psf = PSF.FromBitmap(Picture.Image, new System.Drawing.Point((int)pos.X, (int)pos.Y)); imgPsfPreview.Source = ToBitmap(Psf.ToRawImage()); }