public async Task <IRenderedImage> DetectStars( bool annotateImage, StarSensitivityEnum sensitivity, NoiseReductionEnum noiseReduction, CancellationToken cancelToken = default, IProgress <ApplicationStatus> progress = default(Progress <ApplicationStatus>)) { var starDetection = new StarDetection(this, this.Image.Format, sensitivity, noiseReduction); await starDetection.DetectAsync(progress, cancelToken); var image = annotateImage ? starDetection.GetAnnotatedImage() : this.Image; this.RawImageData.StarDetectionAnalysis.HFR = starDetection.AverageHFR; this.RawImageData.StarDetectionAnalysis.DetectedStars = starDetection.DetectedStars; return(new RenderedImage(image: image, rawImageData: this.RawImageData)); }
public StarDetection(IRenderedImage renderedImage, StarSensitivityEnum sensitivity, NoiseReductionEnum noiseReduction) { var imageData = renderedImage.RawImageData; imageProperties = imageData.Properties; // TODO: StarDetection should probably be more of a static function that returns a result type than a stateful object with awaitable methods // Checking the type of rendered image is a hack until then _iarr = imageData.Data; //If image was debayered, use debayered array for star HFR and local maximum identification if (imageProperties.IsBayered && (renderedImage is IDebayeredImage)) { var debayeredImage = (IDebayeredImage)renderedImage; var debayeredData = debayeredImage.DebayeredData; if (debayeredData != null && debayeredData.Lum != null && debayeredData.Lum.Length > 0) { _iarr = new ImageArray(debayeredData.Lum); } } _originalBitmapSource = renderedImage.Image; _sensitivity = sensitivity; _noiseReduction = noiseReduction; _resizefactor = 1.0; if (imageProperties.Width > _maxWidth) { if (_sensitivity == StarSensitivityEnum.Highest) { _resizefactor = Math.Max(0.625, (double)_maxWidth / imageProperties.Width); } else { _resizefactor = (double)_maxWidth / imageProperties.Width; } } _inverseResizefactor = 1.0 / _resizefactor; _minStarSize = (int)Math.Floor(5 * _resizefactor); //Prevent Hotpixels to be detected if (_minStarSize < 2) { _minStarSize = 2; } _maxStarSize = (int)Math.Ceiling(150 * _resizefactor); }
private void rbNone_CheckedChanged(object sender, EventArgs e) { if (rbNone.Checked) noiseReduction = NoiseReductionEnum.None; else if (rbStrongNoiseReduction.Checked) noiseReduction = NoiseReductionEnum.Strong; else if (rbWeakNoiseReduction.Checked) noiseReduction = NoiseReductionEnum.Weak; }
public StarDetection(IRenderedImage renderedImage, System.Windows.Media.PixelFormat pf, StarSensitivityEnum sensitivity, NoiseReductionEnum noiseReduction) : this(renderedImage, sensitivity, noiseReduction) { if (pf == PixelFormats.Rgb48) { using (var source = ImageUtility.BitmapFromSource(_originalBitmapSource, System.Drawing.Imaging.PixelFormat.Format48bppRgb)) { using (var img = new Grayscale(0.2125, 0.7154, 0.0721).Apply(source)) { _originalBitmapSource = ImageUtility.ConvertBitmap(img, System.Windows.Media.PixelFormats.Gray16); _originalBitmapSource.Freeze(); } } } }