using System;
public class ExtractImageRegion
{
public static int Main(string[] args)
{
string filename = args[0];
if (!reader.ReadInformation()) return 1;
UIntArrayType dims = ImageHelper.GetDimensionsValue(f);
PixelFormat pf = ImageHelper.GetPixelFormatValue (f);
int pixelsize = pf.GetPixelSize();
byte[] buffer = new byte[ dims[0] * dims[1] * pixelsize ];
byte[] buffer2 = new byte[ dims[0] * dims[1] * pixelsize * 3 ];
BoxRegion box = new BoxRegion();
for (uint z = 0; z < dims[2]; z++)
{
box.SetDomain(0, dims[0] - 1, 0, dims[1] - 1, z, z);
reader.SetRegion( box );
if (reader.ReadIntoBuffer(buffer, (uint)buffer.Length))
{
if( !lut.Decode( buffer2, (uint)buffer2.Length, buffer, (uint)buffer.Length ) )
{
throw new Exception("can't decode");
}
using (System.IO.Stream stream =
System.IO.File.Open(@"/tmp/frame_rgb.raw",
System.IO.FileMode.Create))
{
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write(buffer2);
}
}
else
{
throw new Exception("can't read pixels error");
}
}
return 0;
}
}