/// <summary> /// Extracts the specified position as bitmap. /// </summary> /// <param name="axisType">Type of the axis.</param> /// <param name="position">The position.</param> /// <param name="size">The desired output size.</param> /// <returns>The extracted position as bitmap.</returns> public System.Drawing.Bitmap ExtractPosition(AxisType axisType, uint position, uint?size) { Validate(); uint mappedPosition = Mapper == null ? position : Mapper.GetMappedPosition(axisType, position); Image image = itkUtil.ExtractPosition(Image, axisType, mappedPosition); if (axisImages.TryGetValue(axisType, out Image axisImage)) { var filter = new AddImageFilter(); axisImage = filter.Execute(axisImage, image); axisImages[axisType] = axisImage; } else { axisImages.Add(axisType, new Image(image)); } if (size.HasValue && size.Value > 0) { return(itkUtil.ToBitmap(itkUtil.ResampleImage2D(image, size.Value))); } else { return(itkUtil.ToBitmap(image)); } }
/// <inheritdoc/> public System.Drawing.Bitmap ExtractPosition(AxisType axisType, int position, int?size) { Validate(); int mappedPosition = Mapper == null ? position : Mapper.GetMappedPosition(axisType, position); using (Image image = itkUtil.ExtractPosition(Image, axisType, mappedPosition)) { if (size.HasValue && size.Value > 0) { using (var resampledImage = itkUtil.ResampleImage2D(image, size.Value)) { return(itkUtil.ToBitmap(resampledImage)); } } else { return(itkUtil.ToBitmap(image)); } } }