public override async Task <ExecutionResult> RunAsync(IStepExecutionContext context) { Guard.Against.Null(Activity, nameof(Activity)); Guard.Against.Null(TargetImage, nameof(TargetImage)); // Determine visible range of all satellite imagery Activity.GetCropRange(out var latitudeRange, out var longitudeRange); // Load underlay if (_options.NoUnderlay) { // Draw stitched image over black background for non-PNG files because otherwise alpha can look odd TargetImage = !Path.GetExtension(_options.OutputPath).CompareOrdinalIgnoreCase(".png") ? TargetImage.AddBackgroundColour(Color.Black) : TargetImage; return(ExecutionResult.Next()); } _logger.LogInformation("Tinting and normalising IR imagery"); TargetImage.Mutate(imageContext => { using var clone = TargetImage !.Clone(); clone.Mutate(cloneContext => cloneContext.HistogramEqualization()); TargetImage.Tint(_options.Tint); imageContext.DrawImage(clone, PixelColorBlendingMode.HardLight, 0.5f); }); var underlayOptions = new UnderlayProjectionOptions( ProjectionType.Equirectangular, _options.InterpolationType, _options.ImageSize, _options.UnderlayPath, TargetImage !.Height, latitudeRange, longitudeRange); _logger.LogInformation("Retrieving underlay"); var underlay = await _underlayService.GetUnderlayAsync(underlayOptions); // Render target image onto underlay using (TargetImage) { _logger.LogInformation("Blending with underlay"); underlay.Mutate(ctx => ctx.DrawImage(TargetImage, PixelColorBlendingMode.Screen, 1.0f)); } TargetImage = underlay; return(ExecutionResult.Next()); }
public override async Task <ExecutionResult> RunAsync(IStepExecutionContext context) { Guard.Against.Null(_options.GeostationaryRender, nameof(_options.GeostationaryRender)); Guard.Against.Null(Registration?.Image, nameof(Registration.Image)); var targetLongitude = _options.GeostationaryRender.Longitude; if (targetLongitude != null) { throw new InvalidOperationException("Equirectangular composition should be used used when target longitude is provided"); } // Get or generate projected underlay var underlayOptions = new UnderlayProjectionOptions( ProjectionType.Geostationary, _options.InterpolationType, _options.ImageSize, _options.UnderlayPath); _logger.LogInformation("Retrieving underlay"); var underlay = await _underlayService.GetUnderlayAsync(underlayOptions, Registration.Definition); _logger.LogInformation("Tinting and normalising IR imagery"); if (_options.AutoAdjustLevels) { Registration.Image.Mutate(c => c.HistogramEqualization()); } TargetImage = Registration.Image.Clone(); TargetImage.Tint(_options.Tint); _logger.LogInformation("Blending with underlay"); TargetImage.Mutate(c => c .Resize(_options.ImageSize, _options.ImageSize) .DrawImage(underlay, PixelColorBlendingMode.Screen, 1.0f)); return(ExecutionResult.Next()); }
public override async Task <ExecutionResult> RunAsync(IStepExecutionContext context) { Guard.Against.Null(_options.GeostationaryRender, nameof(_options.GeostationaryRender)); Guard.Against.Null(Registration?.Image, nameof(Registration.Image)); if (_options.NoUnderlay) { TargetImage = Registration.Image.Clone(); return(ExecutionResult.Next()); } // Get or generate projected underlay var underlayOptions = new UnderlayProjectionData( ProjectionType.Geostationary, _options.InterpolationType, _options.UnderlayPath, _options.ImageSize); _logger.LogInformation("Retrieving underlay"); var underlay = await _underlayService.GetUnderlayAsync(underlayOptions, Registration.Definition); _logger.LogInformation("Tinting and normalising IR imagery"); if (_options.AutoAdjustLevels) { Registration.Image.AdjustLevels(); } TargetImage = Registration.Image.Clone(); TargetImage.Tint(_options.Tint); _logger.LogInformation("Blending with underlay"); TargetImage.Mutate(c => c .Resize(_options.ImageSize, _options.ImageSize) .DrawImage(underlay, PixelColorBlendingMode.Screen, 1.0f)); return(ExecutionResult.Next()); }