Create a volume from a series of 2D-images given in user-memory. Many 2D images are in user-memory and represent a volume if stacked together. This code shows how to create ImageView from these 2D images, and then create a Volume from these ImageViews.
using System;
using System.Data;
{
public class VolumeFromStack
{
static Byte[] slice_0
= new Byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
static Byte[] slice_1
= new Byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
static Byte[] slice_2
= new Byte[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
static Byte[] slice_3
= new Byte[] { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 };
static Byte[] slice_4
= new Byte[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 };
static Byte[] slice_5
= new Byte[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
static Byte[] slice_6
= new Byte[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
static Byte[] slice_7
= new Byte[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };
static Byte[] slice_8
= new Byte[] { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
static Byte[] slice_9
= new Byte[] { 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 };
static Byte[][] slicesData = new Byte[][] {
slice_0, slice_1, slice_2, slice_3, slice_4, slice_5, slice_6, slice_7, slice_8, slice_9
};
private static ImageView CreateSliceFromRawData(Byte[] data,
{
slice.HasAlpha = false;
return slice;
}
private static ImageView CreateVolumeFromSlices(Byte[][] slices)
{
for (int i = 0; i < slices.Length; ++i)
{
ImageView slice = CreateSliceFromRawData(slices[i], shapeSlice, dtype);
}
}
public static void Main(string[] args)
{
ImageView volume = CreateVolumeFromSlices(slicesData);
}
}
}
Stores information about a data type.
Definition DataType.cs:24
Enum for the image type (see ImageType)
Definition ImageTypeId.cs:20
This factory is aimed at creating dataset views.
Definition ImageViewFactory.cs:21
static ImageView Stack(MultiImageView view, ImageDimension newDimension)
Creates an ImageView from a multiImageView by agglomerating frames into a new given dimension.
Definition ImageViewFactory.cs:578
static ImageView Allocate(VectorXu64 shape, DataType type, ImageProperties properties, MetadataNode metadata)
Creates a memory image with the given shape and type.
Definition ImageViewFactory.cs:86
Interface representing an N dimensional image.
Definition ImageView.cs:30
ReadonlyImageProperties Properties
The ImageProperties associated with this ImageView instance.
Definition ImageView.cs:84
string ToString()
Return a string representation.
Definition ImageView.cs:226
unsafe void WriteRegion(RegionXu64 region, byte[] src)
Write a input buffer into a given region of the image.
Definition ImageView.cs:387
This factory is aimed at creating stack of ImageViews.
Definition MultiImageViewFactory.cs:14
static MultiImageView Create()
Creates an empty MultiImageView.
Definition MultiImageViewFactory.cs:62
Interface representing a multi-image view, i.e. a stack of ImageView.
Definition MultiImageView.cs:19
virtual void AddFrame(ImageView newFrame)
Add a new frame at the end of the set.
Definition MultiImageView.cs:123
A Region using dynamic vectors.
Definition RegionXu64.cs:14
static RegionXu64 CreateFullRegion(VectorXu64 regionSize)
Utility factory that create the region of origin [0, 0, 0] and given size.
Definition RegionXu64.cs:173
A dynamically sized arithmetic vector.
Definition VectorXu64.cs:14
Definition CreateDataFrame.cs:6
Definition AccessCapabilities.cs:11
ImageInterpretation
Interpretation of an Image.
Definition ImageInterpretation.cs:15
ImageDimension
Enum used in ImageType to represent each dimension of an Image.
Definition ImageDimension.cs:15
DataTypeId
A collection of built-in data types.
Definition DataTypeId.cs:15