public ImageRaster2DWrapperSlice3D(IImageRaster <IRaster3DInteger, RangeType> image, int index_2) { Debug.Assert(index_2 < image.Raster.Size2); Raster = new Raster2DInteger(image.Raster.Size0, image.Raster.Size1); this.wrapped_image = image; this.index_2 = index_2; }
public ImageRaster2D( IRaster2DInteger raster, ElementType[] image, bool copy_array) : base(raster, image, copy_array) { }
public Bitmap Render(IImageRaster <IRaster2DInteger, ElementType> source_image) { IRaster2DInteger raster = source_image.Raster; Bitmap destination_image = new Bitmap(raster.Size0, raster.Size1); for (int index_y = 0; index_y < raster.Size1; index_y++) { for (int index_x = 0; index_x < raster.Size0; index_x++) { destination_image.SetPixel(index_x, index_y, converter.Compute(source_image.GetElementValue(raster.GetElementIndex(index_x, index_y)))); } } return(destination_image); }
public ImageRaster2DWrapperSlice4D(IImageRaster <IRaster4DInteger, RangeType> image, int index_2, int index_3) { if (image.Raster.Size2 <= index_2) { throw new Exception("index_2 with value " + index_2 + " out of bounds size_2 = " + image.Raster.Size2); } if (image.Raster.Size3 <= index_3) { throw new Exception("index_3 with value " + index_3 + " out of bounds size_3 = " + image.Raster.Size3); } Raster = new Raster2DInteger(image.Raster.Size0, image.Raster.Size1); this.wrapped_image = image; this.index_2 = index_2; this.index_3 = index_3; }
public static void DistanceTransform2DSlowRBA(ImageRaster2D <bool> mask_image, float[] voxel_size, ImageRaster2D <float> distance_image) { IRaster2DInteger raster = mask_image.Raster; int size_0 = mask_image.Raster.Size0; int size_1 = mask_image.Raster.Size1; // Apply the transform in the x-direction //for (int plane_index = 0; plane_index < size_z * size_y; plane_index++) //{ Parallel.For(0, size_0, index_0 => { for (int index_1 = 0; index_1 < size_1; index_1++) { float best_distance = float.MaxValue; if (mask_image.GetElementValue(index_0, index_1)) { best_distance = 0; } else { for (int index_0_1 = 0; index_0_1 < size_0; index_0_1++) { for (int index_1_1 = 0; index_1_1 < size_1; index_1_1++) { if (mask_image.GetElementValue(index_0_1, index_1_1)) { float distance = ToolsMath.Sqrt(ToolsMath.Sqr((index_0_1 - index_0) * voxel_size[0]) + ToolsMath.Sqr((index_1_1 - index_1) * voxel_size[0])); if (distance < best_distance) { best_distance = distance; } } } } } distance_image.SetElementValue(index_0, index_1, best_distance); } }); }
public ImageRaster2D(IRaster2DInteger raster, ElementType value) : this(raster.Size0, raster.Size1, value) { }
public ImageRaster2D(IRaster2DInteger raster) : this(raster.Size0, raster.Size1) { }