GDCM_NAME_SPACE::RLEFramesInfo Class Reference

Utility class for gathering the informations of the collection of RLE frame[s] (see RLEFrame) when handling "Encapsulated RLE Compressed Images" (see PS 3.5-2003 annex G). Note: a classical image can be considered as the degenerated case of a multiframe image. In this case the collection is limited to a single individual frame. The informations on each frame are obtained during the pixel parsing of a gdcm::File (refer to File::ComputeRLEInfo() ). They shall be used when (if necessary) decoding the frames. More...

#include <gdcmRLEFramesInfo.h>

List of all members.

Private Types

typedef std::list< RLEFrame * > RLEFrameList

Private Member Functions

 ~RLEFramesInfo ()
void Print (std::ostream &os=std::cout, std::string indent="")
 Print self.
bool DecompressRLEFile (std::ifstream *fp, uint8_t *subRaw, int xSize, int ySize, int zSize, int tSize, int bitsAllocated)
 Reads from disk the Pixel Data of 'Run Length Encoded' Dicom encapsulated file and decompress it.
bool ConvertRLE16BitsFromRLE8Bits (uint8_t *subRaw, int xSize, int ySize, int tSize, int numberOfFrames)
 We assume Raw contains the decoded RLE pixels but as 8 bits per pixel. We convert those pixels to 16 bits per pixel.
void AddFrame (RLEFrame *frame)
RLEFrameGetFirstFrame ()
RLEFrameGetNextFrame ()

Private Attributes

RLEFrameList Frames
RLEFrameList::iterator ItFrames

Friends

class PixelReadConvert
class File


Detailed Description

Utility class for gathering the informations of the collection of RLE frame[s] (see RLEFrame) when handling "Encapsulated RLE Compressed Images" (see PS 3.5-2003 annex G). Note: a classical image can be considered as the degenerated case of a multiframe image. In this case the collection is limited to a single individual frame. The informations on each frame are obtained during the pixel parsing of a gdcm::File (refer to File::ComputeRLEInfo() ). They shall be used when (if necessary) decoding the frames.

This class is simply a stl list<> of RLEFrame.

Definition at line 43 of file gdcmRLEFramesInfo.h.


Member Typedef Documentation

typedef std::list<RLEFrame *> GDCM_NAME_SPACE::RLEFramesInfo::RLEFrameList [private]
 

Definition at line 61 of file gdcmRLEFramesInfo.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::RLEFramesInfo::~RLEFramesInfo  )  [private]
 

Definition at line 31 of file gdcmRLEFramesInfo.cxx.

References Frames.

00032 {
00033    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00034    {
00035       delete (*it);
00036    }
00037    Frames.clear();
00038 }


Member Function Documentation

void GDCM_NAME_SPACE::RLEFramesInfo::AddFrame RLEFrame frame  )  [private]
 

Definition at line 42 of file gdcmRLEFramesInfo.cxx.

References Frames.

00043 {
00044    Frames.push_back(frame);
00045 }

bool GDCM_NAME_SPACE::RLEFramesInfo::ConvertRLE16BitsFromRLE8Bits uint8_t *  raw,
int  xSize,
int  ySize,
int  tSize,
int  numberOfFrames
[private]
 

We assume Raw contains the decoded RLE pixels but as 8 bits per pixel. We convert those pixels to 16 bits per pixel.

Parameters:
raw raw
xSize x Size
ySize y Size
tSize t Size
numberOfFrames number of frames
Returns:
Boolean always true

Definition at line 111 of file gdcmRLEFramesInfo.cxx.

References GDCM_NAME_SPACE::Util::IsCurrentProcessorBigEndian().

00114 {
00115    size_t pixelNumber = xSize * ySize * tSize;
00116    size_t rawSize     = pixelNumber * numberOfFrames * 2;
00117 
00118    // We assumed Raw contains the decoded RLE pixels but as
00119    // 8 bits per pixel. In order to convert those pixels to 16 bits
00120    // per pixel we cannot work in place within Raw and hence
00121    // we copy it in a safe place, say copyRaw.
00122 
00123    uint8_t *copyRaw = new uint8_t[rawSize];
00124    memmove( copyRaw, raw, rawSize );
00125 
00126    uint8_t *x = raw;
00127    uint8_t *a;
00128    uint8_t *b;
00129 
00130    // Warning : unckecked patch to see the behaviour on Big Endian Processors
00131 
00132    if ( !Util::IsCurrentProcessorBigEndian() )
00133    { 
00134       a = copyRaw;         // beginning of 'low bytes'
00135       b = a + pixelNumber; // beginning of 'hight bytes'
00136    }
00137    else
00138    {
00139       b = copyRaw;         // beginning of 'low bytes'
00140       a = b + pixelNumber; // beginning of 'hight bytes'
00141    } 
00142 
00143    // Re order bytes
00144    for ( int i = 0; i < numberOfFrames; i++ )
00145    {
00146       for ( unsigned int j = 0; j < pixelNumber; j++ )
00147       {
00148          *(x++) = *(b++);
00149          *(x++) = *(a++);
00150       }
00151    }
00152 
00153    delete[] copyRaw;
00154 
00155    return true;
00156 }

bool GDCM_NAME_SPACE::RLEFramesInfo::DecompressRLEFile std::ifstream *  fp,
uint8_t *  raw,
int  xSize,
int  ySize,
int  zSize,
int  tSize,
int  bitsAllocated
[private]
 

Reads from disk the Pixel Data of 'Run Length Encoded' Dicom encapsulated file and decompress it.

Parameters:
fp already open File Pointer from which the pixel data should be read
raw raw
xSize x Size
ySize y Size
zSize z Size
tSize t Size
bitsAllocated Bits allocated
Returns:
Boolean

Definition at line 78 of file gdcmRLEFramesInfo.cxx.

References Frames.

00081 {
00082    uint8_t *subRaw = raw;
00083    long rawSegmentSize = xSize * ySize * tSize;
00084 
00085    // Loop on the frame[s]
00086    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00087    {
00088       subRaw = (*it)->ReadAndDecompressRLEFrame( subRaw, rawSegmentSize, fp);
00089    }
00090 
00091    if ( bitsAllocated == 16 )
00092    {
00093       // Try to deal with RLE 16 Bits
00094       ConvertRLE16BitsFromRLE8Bits( raw, xSize, ySize, zSize, tSize );
00095    }
00096 
00097    return true;
00098 }

RLEFrame * GDCM_NAME_SPACE::RLEFramesInfo::GetFirstFrame  )  [private]
 

Definition at line 47 of file gdcmRLEFramesInfo.cxx.

References Frames, and ItFrames.

00048 {
00049    ItFrames = Frames.begin();
00050    if (ItFrames != Frames.end())
00051       return  *ItFrames;
00052    return NULL;
00053 }

RLEFrame * GDCM_NAME_SPACE::RLEFramesInfo::GetNextFrame  )  [private]
 

Definition at line 55 of file gdcmRLEFramesInfo.cxx.

References Frames, gdcmAssertMacro, and ItFrames.

00056 {
00057    gdcmAssertMacro (ItFrames != Frames.end());
00058 
00059    ++ItFrames;
00060    if (ItFrames != Frames.end())
00061       return  *ItFrames;
00062    return NULL;
00063 }

void GDCM_NAME_SPACE::RLEFramesInfo::Print std::ostream &  os = std::cout,
std::string  indent = ""
[private]
 

Print self.

Parameters:
indent Indentation string to be prepended during printing.
os Stream to print to.
Todo:
: find an example, to know haow 3rd and 4th dimension works together

Definition at line 171 of file gdcmRLEFramesInfo.cxx.

References Frames.

00172 {
00173    os << std::endl;
00174    os << indent
00175       << "----------------- RLE frames --------------------------------"
00176       << std::endl;
00177    os << indent
00178       << "Total number of Frames : " << Frames.size()
00179       << std::endl;
00180    int frameNumber = 0;
00183    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00184    {
00185       os << indent
00186          << "   frame number :" << frameNumber++
00187          << std::endl;
00188       (*it)->Print( os, indent + "   " );
00189    }
00190 }


Friends And Related Function Documentation

friend class File [friend]
 

Definition at line 46 of file gdcmRLEFramesInfo.h.

friend class PixelReadConvert [friend]
 

Definition at line 45 of file gdcmRLEFramesInfo.h.


Member Data Documentation

RLEFrameList GDCM_NAME_SPACE::RLEFramesInfo::Frames [private]
 

Definition at line 63 of file gdcmRLEFramesInfo.h.

Referenced by AddFrame(), DecompressRLEFile(), GetFirstFrame(), GetNextFrame(), Print(), and ~RLEFramesInfo().

RLEFrameList::iterator GDCM_NAME_SPACE::RLEFramesInfo::ItFrames [private]
 

Definition at line 64 of file gdcmRLEFramesInfo.h.

Referenced by GetFirstFrame(), and GetNextFrame().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:54 2007 for gdcm by  doxygen 1.4.6