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(); } } } }
public void Init() { filterWheelMediatorMock = new Mock <IFilterWheelMediator>(); profileServiceMock = new Mock <IProfileService>(); imagingVMMock = new Mock <IImagingVM>(); cameraMediatorMock = new Mock <ICameraMediator>(); telescopeMediatorMock = new Mock <ITelescopeMediator>(); applicationStatusMediatorMock = new Mock <IApplicationStatusMediator>(); exposureServiceMock = new Mock <IFlatWizardExposureTimeFinderService>(); localeMock = new Mock <ILoc>(); filterWheelSettingsMock = new Mock <IFilterWheelSettings>(); _flatDeviceMediatorMock = new Mock <IFlatDeviceMediator>(); profileMock = new Mock <IProfile>(); flatWizardSettingsMock = new Mock <IFlatWizardSettings>(); cameraSettingsMock = new Mock <ICameraSettings>(); resourceDictionaryMock = new Mock <IApplicationResourceDictionary>(); profileServiceMock.SetupGet(m => m.ActiveProfile).Returns(profileMock.Object); profileMock.SetupGet(m => m.FlatWizardSettings).Returns(flatWizardSettingsMock.Object); profileMock.SetupGet(m => m.CameraSettings).Returns(cameraSettingsMock.Object); profileMock.SetupGet(m => m.FilterWheelSettings).Returns(filterWheelSettingsMock.Object); profileServiceMock.Setup(m => m.ActiveProfile.ImageSettings.AutoStretchFactor).Returns(1.0); profileServiceMock.Setup(m => m.ActiveProfile.ImageSettings.BlackClipping).Returns(0.1); profileServiceMock.Setup(m => m.ActiveProfile.ImageFileSettings.FilePath).Returns(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName); filterWheelSettingsMock.SetupGet(m => m.FilterWheelFilters) .Returns(new ObserveAllCollection <FilterInfo>()); _camera = new SimulatorCamera(profileServiceMock.Object, telescopeMediatorMock.Object) { Settings = { Type = CameraType.RANDOM, RandomSettings = { ImageMean = 32000, ImageStdDev = 1000 } } }; _image = _camera.DownloadExposure(new CancellationToken()).Result.ToImageData().Result.RenderImage(); localeMock.SetupGet(m => m[It.IsAny <string>()]).Returns("Test"); imagingVMMock.Setup(m => m.CaptureAndPrepareImage(It.IsAny <CaptureSequence>(), It.IsAny <PrepareImageParameters>(), It.IsAny <CancellationToken>(), It.IsAny <IProgress <ApplicationStatus> >())).ReturnsAsync(_image); _flatDevice = new FlatDeviceInfo() { Brightness = 1.0, Connected = true, CoverState = CoverState.Open, Description = "Some description", DriverInfo = "Some driverInfo", LightOn = false, DriverVersion = "200", MaxBrightness = 255, MinBrightness = 0, Name = "Some name" }; }
public static IDebayeredImage Debayer( IRenderedImage imageData, bool saveColorChannels = false, bool saveLumChannel = false, SensorType bayerPattern = SensorType.RGGB) { var debayeredImage = ImageUtility.Debayer(imageData.Image, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale, saveColorChannels, saveLumChannel, bayerPattern); return(new DebayeredImage( image: debayeredImage.ImageSource, rawImageData: imageData.RawImageData, debayeredData: debayeredImage.Data, saveColorChannels: saveColorChannels, saveLumChannels: saveLumChannel)); }
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); }
public static Task <BitmapSource> Stretch(IRenderedImage image, double factor, double blackClipping) { return(Task.Run(async() => { var imageStatistics = await image.RawImageData.Statistics.Task; if (image.Image.Format == PixelFormats.Gray16) { using (var bmp = ImageUtility.BitmapFromSource(image.Image, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale)) { return Stretch(imageStatistics, bmp, image.Image.Format, factor, blackClipping); } } else if (image.Image.Format == PixelFormats.Rgb48) { using (var bmp = ImageUtility.BitmapFromSource(image.Image, System.Drawing.Imaging.PixelFormat.Format48bppRgb)) { return Stretch(imageStatistics, bmp, image.Image.Format, factor, blackClipping); } } else { throw new NotSupportedException(); } })); }