using System;
public class ExtractOneFrame
{
public static int Main(string[] args)
{
string filename = args[0];
uint dimx = extent[0];
uint dimy = extent[1];
uint dimz = extent[2];
byte[] buffer = new byte[ dimx * dimy * pixelsize ];
for (int i = 0; i < dimz; i++)
{
reader.
DefinePixelExtent(0, (ushort)dimx, 0, (ushort)dimy, (ushort)i, (ushort)(i+1));
if( buf_len > buffer.Length )
{
throw new Exception(
"buffer is too small for target");
}
if (reader.
Read(buffer, (uint)buffer.Length))
{
using (System.IO.Stream stream =
System.IO.File.Open(
@"/tmp/frame.raw",
{
System.IO.BinaryWriter writer =
new System.IO.BinaryWriter(stream);
writer.Write(buffer);
}
}
else
{
throw new Exception(
"can't read pixels error");
}
}
return 0;
}
}
Exception.
Definition gdcmException.h:44
a DICOM File
Definition gdcmFile.h:34
ImageHelper (internal class, not intended for user level)
Definition gdcmImageHelper.h:60
static std::vector< unsigned int > GetDimensionsValue(const File &f)
StreamImageReader.
Definition gdcmStreamImageReader.h:39
void DefinePixelExtent(uint16_t inXMin, uint16_t inXMax, uint16_t inYMin, uint16_t inYMax, uint16_t inZMin=0, uint16_t inZMax=1)
virtual bool ReadImageInformation()
bool Read(char *inReadBuffer, const std::size_t &inBufferLength)
void SetFileName(const char *inFileName)
File const & GetFile() const
uint32_t DefineProperBufferLength() const
Class to do system operation.
Definition gdcmSystem.h:27