GDCM_NAME_SPACE::PixelWriteConvert Class Reference

#include <gdcmPixelWriteConvert.h>

Inheritance diagram for GDCM_NAME_SPACE::PixelWriteConvert:

Inheritance graph
[legend]
Collaboration diagram for GDCM_NAME_SPACE::PixelWriteConvert:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void Print (std::ostream &=std::cout, std::string const &="")
 Printer.
void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.
int GetPrintLevel ()
 Gets the print level for the Dicom Entries.

Protected Attributes

int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Private Member Functions

 PixelWriteConvert ()
 Constructor.
virtual ~PixelWriteConvert ()
 Destructor.
void SetReadData (uint8_t *data, size_t size)
 sets Read Data (and size)
uint8_t * GetReadData ()
 returns ReadData
size_t GetReadDataSize ()
 returns ReadDataSize
void SetUserData (uint8_t *data, size_t size)
 Sets the internal pointer to the caller's inData image representation, WITHOUT COPYING THE DATA.
  • 'image' Pixels are presented as C-like 2D arrays : line per line.
  • 'volume'Pixels are presented as C-like 3D arrays : plane per plane.

uint8_t * GetUserData ()
 returns UserData
size_t GetUserDataSize ()
 returns UserDataSize
uint8_t * GetData ()
 Get Data (UserData or ReadData).
size_t GetDataSize ()
 Get Data Size (UserData or ReadData).
void SetCompressJPEG2000UserData (uint8_t *data, size_t size, File *image)
void SetCompressJPEGUserData (uint8_t *data, size_t size, File *image)

Private Attributes

uint8_t * ReadData
 Pixel data represented as RGB after LUT color interpretation.
size_t ReadDataSize
 Size of RGB image.
uint8_t * UserData
 User pixel data.
size_t UserDataSize
 Size of User image.
bool Compressed
 Whether we want to write compressed or not.

Friends

class FileHelper

Detailed Description

Definition at line 35 of file gdcmPixelWriteConvert.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::PixelWriteConvert::PixelWriteConvert  )  [private]
 

Constructor.

Definition at line 43 of file gdcmPixelWriteConvert.cxx.

References Compressed, ReadData, ReadDataSize, UserData, and UserDataSize.

00044 {
00045    ReadData     = 0;
00046    ReadDataSize = 0;
00047 
00048    UserData     = 0;
00049    UserDataSize = 0;
00050    Compressed   = false;
00051 }

GDCM_NAME_SPACE::PixelWriteConvert::~PixelWriteConvert  )  [private, virtual]
 

Destructor.

Definition at line 56 of file gdcmPixelWriteConvert.cxx.

References Compressed, gdcmDebugMacro, and UserData.

00057 {
00058    gdcmDebugMacro("PixelWriteConvert::~PixelWriteConvert()" );
00059    if( Compressed )
00060      {
00061      delete[] UserData;
00062      }
00063 }


Member Function Documentation

uint8_t * GDCM_NAME_SPACE::PixelWriteConvert::GetData  )  [private]
 

Get Data (UserData or ReadData).

Returns:
data (uint8_t is for prototyping. if your data is *not* uint8_t just cast the returned pointer)

Definition at line 100 of file gdcmPixelWriteConvert.cxx.

References ReadData, and UserData.

00101 {
00102    if ( UserData )
00103    {
00104       return UserData;
00105    }
00106    else
00107    {
00108       return ReadData;
00109    }
00110 }

size_t GDCM_NAME_SPACE::PixelWriteConvert::GetDataSize  )  [private]
 

Get Data Size (UserData or ReadData).

Returns:
size, in bytes.

Definition at line 116 of file gdcmPixelWriteConvert.cxx.

References ReadDataSize, UserData, and UserDataSize.

00117 {
00118    if ( UserData )
00119    {
00120       return UserDataSize;
00121    }
00122    else
00123    {
00124       return ReadDataSize;
00125    }
00126 }

int GDCM_NAME_SPACE::Base::GetPrintLevel  )  [inline, inherited]
 

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

uint8_t* GDCM_NAME_SPACE::PixelWriteConvert::GetReadData  )  [inline, private]
 

returns ReadData

Definition at line 46 of file gdcmPixelWriteConvert.h.

00046 { return ReadData; }

size_t GDCM_NAME_SPACE::PixelWriteConvert::GetReadDataSize  )  [inline, private]
 

returns ReadDataSize

Definition at line 48 of file gdcmPixelWriteConvert.h.

00048 { return ReadDataSize; }

uint8_t* GDCM_NAME_SPACE::PixelWriteConvert::GetUserData  )  [inline, private]
 

returns UserData

Definition at line 53 of file gdcmPixelWriteConvert.h.

Referenced by GDCM_NAME_SPACE::FileHelper::CheckWriteIntegrity(), GDCM_NAME_SPACE::FileHelper::GetImageData(), GDCM_NAME_SPACE::FileHelper::GetImageDataRawSize(), GDCM_NAME_SPACE::FileHelper::GetImageDataSize(), GDCM_NAME_SPACE::FileHelper::GetUserData(), and GDCM_NAME_SPACE::FileHelper::WriteRawData().

00053 { return UserData; }

size_t GDCM_NAME_SPACE::PixelWriteConvert::GetUserDataSize  )  [inline, private]
 

returns UserDataSize

Definition at line 55 of file gdcmPixelWriteConvert.h.

Referenced by GDCM_NAME_SPACE::FileHelper::CheckWriteIntegrity(), GDCM_NAME_SPACE::FileHelper::GetImageDataRawSize(), GDCM_NAME_SPACE::FileHelper::GetImageDataSize(), GDCM_NAME_SPACE::FileHelper::GetUserDataSize(), and GDCM_NAME_SPACE::FileHelper::WriteRawData().

00055 { return UserDataSize; }

virtual void GDCM_NAME_SPACE::Base::Print std::ostream &  = std::cout,
std::string const &  = ""
[inline, virtual, inherited]
 

Printer.

Reimplemented in GDCM_NAME_SPACE::CommandManager, GDCM_NAME_SPACE::DataEntry, GDCM_NAME_SPACE::DicomDir, GDCM_NAME_SPACE::DicomDirElement, GDCM_NAME_SPACE::DicomDirImage, GDCM_NAME_SPACE::DicomDirMeta, GDCM_NAME_SPACE::DicomDirPatient, GDCM_NAME_SPACE::DicomDirPrivate, GDCM_NAME_SPACE::DicomDirSerie, GDCM_NAME_SPACE::DicomDirStudy, GDCM_NAME_SPACE::DicomDirVisit, GDCM_NAME_SPACE::DicomEntry, GDCM_NAME_SPACE::Dict, GDCM_NAME_SPACE::DictEntry, GDCM_NAME_SPACE::DictGroupName, GDCM_NAME_SPACE::DictSet, GDCM_NAME_SPACE::DirList, GDCM_NAME_SPACE::DocEntry, GDCM_NAME_SPACE::ElementSet, GDCM_NAME_SPACE::FileHelper, GDCM_NAME_SPACE::JPEGFragment, GDCM_NAME_SPACE::PixelReadConvert, GDCM_NAME_SPACE::RLEFrame, GDCM_NAME_SPACE::SeqEntry, GDCM_NAME_SPACE::SerieHelper, GDCM_NAME_SPACE::SQItem, GDCM_NAME_SPACE::TS, and GDCM_NAME_SPACE::VR.

Definition at line 42 of file gdcmBase.h.

00043                                                {};

void GDCM_NAME_SPACE::PixelWriteConvert::SetCompressJPEG2000UserData uint8_t *  data,
size_t  size,
File image
[private]
 

Definition at line 236 of file gdcmPixelWriteConvert.cxx.

References Compressed, GDCM_NAME_SPACE::EncodeWithBasicOffsetTable(), GDCM_NAME_SPACE::EncodeWithoutBasicOffsetTable(), GDCM_NAME_SPACE::gdcm_write_JPEG2000_file(), GDCM_NAME_SPACE::File::GetBitsAllocated(), GDCM_NAME_SPACE::File::GetSamplesPerPixel(), GDCM_NAME_SPACE::File::GetXSize(), GDCM_NAME_SPACE::File::GetYSize(), GDCM_NAME_SPACE::File::GetZSize(), GDCM_NAME_SPACE::File::IsSignedPixelData(), and GDCM_NAME_SPACE::WriteDICOMItems().

Referenced by GDCM_NAME_SPACE::FileHelper::SetUserData().

00237 {
00238   Compressed = true;
00239   //char * userData = reinterpret_cast<char*>(UserData);
00240 
00241    std::ostringstream *of = new std::ostringstream();
00242     int xsize = image->GetXSize();
00243    int ysize = image->GetYSize();
00244   int zsize =  image->GetZSize();
00245     int samplesPerPixel = image->GetSamplesPerPixel();
00246    //std::cout << "X: " << xsize << std::endl;
00247    //std::cout << "Y: " << ysize << std::endl;
00248    //std::cout << "Sample: " << samplesPerPixel << std::endl;
00249     int bitsallocated = image->GetBitsAllocated();
00250     int sign = image->IsSignedPixelData();
00251    unsigned int fragment_size = xsize*ysize*samplesPerPixel * (bitsallocated / 8);
00252     assert( fragment_size*zsize == size );
00253 
00254    JpegVector JpegFragmentSize;
00255 #if WITHOFFSETTABLE
00256    size_t bots; //basic offset table start
00257    EncodeWithBasicOffsetTable(of, zsize, bots);
00258 #else
00259    EncodeWithoutBasicOffsetTable(of, 1);
00260 #endif
00261    uint8_t *pImageData = data;
00262    for(int i=0; i<zsize;i++)
00263      {
00264      WriteDICOMItems(of, JpegFragmentSize);
00265      size_t beg = of->tellp();
00266      gdcm_write_JPEG2000_file(of, (char*)pImageData,size, 
00267        image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(),
00268        image->GetBitsAllocated(), sign, 100);
00269      //userData, UserDataSize);
00270      //     CreateOneFrame(of, pImageData, fragment_size, xsize, ysize, zsize, 
00271      //       samplesPerPixel, quality, JpegFragmentSize);
00272      //assert( !(fragment_size % 2) );
00273      // Update the JpegVector with offset
00274      size_t end = of->tellp();
00275      //static int i = 0;
00276      JpegPair &jp = JpegFragmentSize[i];
00277      jp.second = (uint32_t)(end-beg);
00278      if( ((end-beg) % 2) )
00279        {
00280        of->put( '\0' );
00281        jp.second += 1;
00282        }
00283      assert( !(jp.second % 2) );
00284      //std::cerr << "DIFF: " << i <<" -> " << jp.second << std::endl;
00285      //++i;
00286      pImageData += fragment_size;
00287      }
00288    CloseJpeg(of, JpegFragmentSize);
00289 #if WITHOFFSETTABLE
00290    UpdateBasicOffsetTable(of, JpegFragmentSize, bots);
00291 #endif
00292 
00293 
00294    size_t of_size = of->str().size();
00295    UserData = new uint8_t[of_size];
00296    memcpy(UserData, of->str().c_str(), of_size);
00297    UserDataSize = of_size;
00298    delete of;   
00299 }

void GDCM_NAME_SPACE::PixelWriteConvert::SetCompressJPEGUserData uint8_t *  data,
size_t  size,
File image
[private]
 

Definition at line 311 of file gdcmPixelWriteConvert.cxx.

References Compressed, GDCM_NAME_SPACE::EncodeWithBasicOffsetTable(), GDCM_NAME_SPACE::EncodeWithoutBasicOffsetTable(), GDCM_NAME_SPACE::gdcm_write_JPEG_file12(), GDCM_NAME_SPACE::gdcm_write_JPEG_file16(), GDCM_NAME_SPACE::gdcm_write_JPEG_file8(), GDCM_NAME_SPACE::File::GetBitsAllocated(), GDCM_NAME_SPACE::File::GetSamplesPerPixel(), GDCM_NAME_SPACE::File::GetXSize(), GDCM_NAME_SPACE::File::GetYSize(), GDCM_NAME_SPACE::File::GetZSize(), and GDCM_NAME_SPACE::WriteDICOMItems().

Referenced by GDCM_NAME_SPACE::FileHelper::SetUserData().

00312 {
00313   (void)data;
00314   (void)size;
00315   (void)image;
00316   Compressed = true;
00317   //char * userData = reinterpret_cast<char*>(UserData);
00318 
00319    std::ostringstream *of = new std::ostringstream();
00320     int xsize = image->GetXSize();
00321     int ysize = image->GetYSize();
00322     int zsize = image->GetZSize();
00323     int samplesPerPixel = image->GetSamplesPerPixel();
00324    //std::cout << "X: " << xsize << std::endl;
00325    //std::cout << "Y: " << ysize << std::endl;
00326    //std::cout << "Sample: " << samplesPerPixel << std::endl;
00327     int bitsallocated = image->GetBitsAllocated();
00328    unsigned int fragment_size = xsize*ysize*samplesPerPixel * (bitsallocated / 8);
00329     assert( fragment_size*zsize == size );
00330 
00331    JpegVector JpegFragmentSize;
00332 #if WITHOFFSETTABLE
00333    size_t bots; //basic offset table start
00334    EncodeWithBasicOffsetTable(of, zsize, bots);
00335 #else
00336    EncodeWithoutBasicOffsetTable(of, 1);
00337 #endif
00338    uint8_t *pImageData = data;
00339    for(int i=0; i<zsize;i++)
00340      {
00341      WriteDICOMItems(of, JpegFragmentSize);
00342   size_t beg = of->tellp();
00343      if( bitsallocated == 8 )
00344        {
00345        gdcm_write_JPEG_file8(of, (char*)pImageData,size, 
00346          image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(),
00347          image->GetBitsAllocated(), 100 );
00348        }
00349      else if (bitsallocated <= 12)
00350        {
00351        assert( bitsallocated >= 8 );
00352        gdcm_write_JPEG_file12(of, (char*)pImageData,size, 
00353          image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(),
00354          image->GetBitsAllocated(), 100);
00355        }
00356      else if (bitsallocated <= 16)
00357        {
00358        assert( bitsallocated >= 12 );
00359        gdcm_write_JPEG_file16(of, (char*)pImageData,size, 
00360          image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(),
00361          image->GetBitsAllocated(), 100);
00362        }
00363      else
00364        {
00365        abort();
00366        }
00367     size_t end = of->tellp();
00368     //static int i = 0;
00369     JpegPair &jp = JpegFragmentSize[i];
00370       jp.second = (uint32_t)(end-beg);
00371     if( ((end-beg) % 2) )
00372       {
00373       of->put( '\0' );
00374       jp.second += 1;
00375       }
00376     assert( !(jp.second % 2) );
00377     //std::cerr << "DIFF: " << i <<" -> " << jp.second << std::endl;
00378     //++i;
00379 
00380   //JpegPair &jp = v[0];
00381   //jp.second = 15328;
00382 
00383 
00384      //userData, UserDataSize);
00385      //     CreateOneFrame(of, pImageData, fragment_size, xsize, ysize, zsize, 
00386      //       samplesPerPixel, quality, JpegFragmentSize);
00387      //assert( !(fragment_size % 2) );
00388      pImageData += fragment_size;
00389      }
00390    CloseJpeg(of, JpegFragmentSize);
00391 #if WITHOFFSETTABLE
00392    UpdateBasicOffsetTable(of, JpegFragmentSize, bots);
00393 #endif
00394 
00395 
00396    size_t of_size = of->str().size();
00397    UserData = new uint8_t[of_size];
00398    memcpy(UserData, of->str().c_str(), of_size);
00399    UserDataSize = of_size;
00400    delete of;
00401 }

void GDCM_NAME_SPACE::Base::SetPrintLevel int  level  )  [inline, inherited]
 

Sets the print level for the Dicom Header Elements.

Note:
0 for Light Print; 1 for 'medium' Print, 2 for Heavy Print

Definition at line 47 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::FileHelper::Print(), and GDCM_NAME_SPACE::DicomDir::Print().

00047 { PrintLevel = level; }

void GDCM_NAME_SPACE::PixelWriteConvert::SetReadData uint8_t *  data,
size_t  size
[private]
 

sets Read Data (and size)

Parameters:
data data (uint8_t is for prototyping. if your data is not uint8_t just cast the pointer for calling the method)
size data size, in bytes

Definition at line 71 of file gdcmPixelWriteConvert.cxx.

References ReadData, and ReadDataSize.

Referenced by GDCM_NAME_SPACE::FileHelper::SetWriteToRGB().

00072 {
00073    ReadData = data;
00074    ReadDataSize = size;
00075 }

void GDCM_NAME_SPACE::PixelWriteConvert::SetUserData uint8_t *  data,
size_t  size
[private]
 

Sets the internal pointer to the caller's inData image representation, WITHOUT COPYING THE DATA.

  • 'image' Pixels are presented as C-like 2D arrays : line per line.
  • 'volume'Pixels are presented as C-like 3D arrays : plane per plane.

Warning:
Since the pixels are not copied, it is the caller's responsability not to deallocate its data before gdcm uses them (e.g. with the Write() method )
Parameters:
data data (uint8_t is for prototyping. if your data is not uint8_t just cast the pointer for calling the method)
size size, in bytes.

Definition at line 89 of file gdcmPixelWriteConvert.cxx.

References UserData, and UserDataSize.

Referenced by GDCM_NAME_SPACE::FileHelper::SetImageData(), and GDCM_NAME_SPACE::FileHelper::SetUserData().

00090 {
00091    UserData = data;
00092    UserDataSize = size;
00093 }


Friends And Related Function Documentation

friend class FileHelper [friend]
 

Definition at line 37 of file gdcmPixelWriteConvert.h.


Member Data Documentation

bool GDCM_NAME_SPACE::PixelWriteConvert::Compressed [private]
 

Whether we want to write compressed or not.

Definition at line 76 of file gdcmPixelWriteConvert.h.

Referenced by PixelWriteConvert(), SetCompressJPEG2000UserData(), SetCompressJPEGUserData(), and ~PixelWriteConvert().

int GDCM_NAME_SPACE::Base::PrintLevel [protected, inherited]
 

Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Definition at line 55 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::SeqEntry::Print(), GDCM_NAME_SPACE::FileHelper::Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::DocEntry::Print(), GDCM_NAME_SPACE::DictEntry::Print(), GDCM_NAME_SPACE::DicomDirStudy::Print(), GDCM_NAME_SPACE::DicomDirSerie::Print(), GDCM_NAME_SPACE::DicomDirPatient::Print(), GDCM_NAME_SPACE::DicomDirMeta::Print(), GDCM_NAME_SPACE::DicomDir::Print(), and GDCM_NAME_SPACE::DataEntry::Print().

uint8_t* GDCM_NAME_SPACE::PixelWriteConvert::ReadData [private]
 

Pixel data represented as RGB after LUT color interpretation.

Definition at line 66 of file gdcmPixelWriteConvert.h.

Referenced by GetData(), PixelWriteConvert(), and SetReadData().

size_t GDCM_NAME_SPACE::PixelWriteConvert::ReadDataSize [private]
 

Size of RGB image.

Definition at line 68 of file gdcmPixelWriteConvert.h.

Referenced by GetDataSize(), PixelWriteConvert(), and SetReadData().

uint8_t* GDCM_NAME_SPACE::PixelWriteConvert::UserData [private]
 

User pixel data.

Definition at line 71 of file gdcmPixelWriteConvert.h.

Referenced by GetData(), GetDataSize(), PixelWriteConvert(), SetUserData(), and ~PixelWriteConvert().

size_t GDCM_NAME_SPACE::PixelWriteConvert::UserDataSize [private]
 

Size of User image.

Definition at line 73 of file gdcmPixelWriteConvert.h.

Referenced by GetDataSize(), PixelWriteConvert(), and SetUserData().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 12:57:20 2007 for gdcm by  doxygen 1.4.6