This code demonstrates how to create an image view on disk and write/read data to/from it. The code creates a 3D image of size 100x100x100 without allocating any CPU memory, and writes a line of data in each slice. Finally, it then reads and prints the value of the last written sample.
using System;
using System.Runtime.Intrinsics;
{
public class DiskImageView
{
{
double[] lineBuffer = new double[shape[0]];
Console.WriteLine("Writing data slice by slice, line by line");
double valueInit = 0;
for (ulong i = 0; i < shape[2]; ++i)
{
for (ulong j = 0; j < shape[1]; ++j)
{
for (ulong k = 0; k < shape[0]; ++k)
{
lineBuffer[k] = valueInit;
}
valueInit++;
}
}
Console.WriteLine("Writing completed");
return image;
}
public static void Main(string[] args)
{
var image = Generate();
Console.WriteLine("Reading Last Sample");
byte[] bytearr = new byte[8];
double value = BitConverter.ToDouble(bytearr, 0);
Console.WriteLine("Last Sample Value: " + value);
Console.WriteLine("SUCCESS");
}
}
}
Stores information about a data type.
Definition DataType.cs:24
This factory is aimed at creating dataset views.
Definition ImageViewFactory.cs:21
static ImageView CreateOnDisk(string dirPath, VectorXu64 shape, DataType type, ImageProperties properties, MetadataNode metadata)
Create an image with the data stored into a temporary file (in given folder) on disk in raw.
Definition ImageViewFactory.cs:143
Interface representing an N dimensional image.
Definition ImageView.cs:30
unsafe void WriteRegion(RegionXu64 region, byte[] src)
Write a input buffer into a given region of the image.
Definition ImageView.cs:387
A Region using dynamic vectors.
Definition RegionXu64.cs:14
A dynamically sized arithmetic vector.
Definition VectorXu64.cs:14
Definition CreateDataFrame.cs:6
Definition AccessCapabilities.cs:11
DataTypeId
A collection of built-in data types.
Definition DataTypeId.cs:15