This code demonstrates how it is possible to copy a whole ImageView content into another one.
using System;
{
public class CopyImageView
{
{
image.HasAlpha = false;
image.SpatialOrigin =
new Vector3d(1.0, 2.0, 3.0);
image.SpatialSpacing =
new Vector3d(0.1, 0.2, 0.3);
image.SpatialUnit = "mm";
image.Metadata = rootNode;
Byte[] buffer =
new byte[image.Type.ByteCount() * fullRegion.
ElementCount];
Array.Fill<Byte>(buffer, 0x42);
image.WriteRegion(fullRegion, buffer);
return image;
}
{
{
throw new ApplicationException("Source image does not have READ capability");
}
{
throw new ApplicationException(
"Destination image does not have WRITE and RESHAPE capability");
}
}
public static void Main(string[] args)
{
var imageSrc = CreateImageView();
CopyImageViewContent(imageSrc, imageDst);
Console.WriteLine(imageSrc.ToString());
Console.WriteLine(imageSrc.Properties.Clone().ToString());
Console.WriteLine(imageSrc.Metadata.Clone().ToString());
}
}
}
Stores information about a data type.
Definition DataType.cs:24
uint ByteCount()
Get the number of bits required to store the type.
Definition DataType.cs:282
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 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
ReadonlyMetadataNode Metadata
The MetadataNode associated with this ImageView instance.
Definition ImageView.cs:92
ReadonlyImageProperties Properties
The ImageProperties associated with this ImageView instance.
Definition ImageView.cs:84
VectorXu64 Shape
The ImageView shape, the size of each of its dimensions.
Definition ImageView.cs:71
DataType Type
The type of the image's elements.
Definition ImageView.cs:77
unsafe void ReadRegion(RegionXu64 region, byte[] dst)
Read a region of the image into a buffer.
Definition ImageView.cs:270
bool Support(ImageCapabilitySet flags)
Checks if the ImageView supports the given capabilities.
Definition ImageView.cs:177
unsafe void WriteRegion(RegionXu64 region, byte[] src)
Write a input buffer into a given region of the image.
Definition ImageView.cs:387
virtual void Reshape(VectorXu64 shape, DataType dataType)
Change the shape and sample data type of the image.
Definition ImageView.cs:465
A Region using dynamic vectors.
Definition RegionXu64.cs:14
uint ElementCount
The number of elements in this region.
Definition RegionXu64.cs:139
static RegionXu64 CreateFullRegion(VectorXu64 regionSize)
Utility factory that create the region of origin [0, 0, 0] and given size.
Definition RegionXu64.cs:173
A factory to create VariantDataValue instances from a great variety of types.
Definition VariantDataValueFactory.cs:14
An arithmetic vector.
Definition Vector3d.cs:29
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
ImageCapability
Define capabilities of an ImageView.
Definition ImageCapability.cs:15
DataTypeId
A collection of built-in data types.
Definition DataTypeId.cs:15