Next step is to load the pixels in memory.
Uncompression (JPEG lossless, JPEG lossy, JPEG 2000, RLE, ...)
-is automatically performed if necessary.
+will be automatically performed if necessary.
+
+You first have to create a 'File Helper'
gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
+
+In some images,(where BitsAllocated=16, BitsUsed=8),
+the 'unused bits' are actually ... used for storing 'overlays'.
+(e.g. : Patient / Aquisition / Institution informations, or drawings ...)
+It's up to you to decide whether you want or not to load the overlays.
+(Probabely, if you want to post-process the images, you dont' want!)
+
+ fh->SetKeepOverlays(true); // default is : false
+
void *imageData = fh->GetImageDataRaw();
uint32_t dataSize = fh->GetImageDataRawSize();
int dimZ = f->GetZSize(); // meaningfull only for 'Volumes' or 'multiframe files'
int dimT = f->GetTSize(); // meaningfull only for 4D objects (?)
-Now, you can enjoy your image !
-
Sometimes, you deal with 'colour' images :-(
They may be stored, on disc, as :
RGB pixels,
gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
void *imageData = fh->GetImageDataRaw();
uint32_t dataSize = fh->GetImageDataRawSize();
+
+Now, you can enjoy your image !
1-1-1-3) Get the value of a single Dicom DataElement
// -------- skip this one, for a first reading ! -----------
Sometimes, the Serie UID is not enough to disseminate properly the images.
-We may want to disseminate into multiple sub serie when needed.
+We may want to disseminate into multiple sub series when needed.
Use :
void SerieHelper::SetUseSeriesDetails(bool s);
vtkGdcmReader *reader = vtkGdcmReader::New();
reader->SetFileName( yourDicomFilename );
- reader->SetLoadMode( yourLoadMode); // See C++ part
+ reader->SetLoadMode( yourLoadMode); // See C++ part
+ reader->SetKeepOverlays( true/false); // See C++ part
reader->Update();
vtkImageData* ima = reader->GetOutput();
- int* Size = ima->GetDimensions();
+ int* Size = ima->GetDimensions();
+
// -> Enjoy it.
1-2-2) A File Set
vtkGdcmReader *reader = vtkGdcmReader::New();
for(int i=1; i< yourNumberOfFiles; i++)
reader->AddFileName( yourTableOfFileNames[i] );
- reader->SetLoadMode( yourLoadMode); // See C++ part
+ reader->SetLoadMode( yourLoadMode); // See C++ part
+ reader->SetKeepOverlays( true/false); // See C++ part
reader->Update();
vtkImageData* ima = reader->GetOutput();
int* Size = ima->GetDimensions();
+
// -> Enjoy it.
Warning : The first file is assumed to be the reference file.
file->InsertEntryString(str.str(),0x0028,0x0002, "US"); // Samples per Pixel
//--> Set Optional fields
- se further how to deal with optional fields
+ see further how to deal with optional fields
//--> Create a gdcm::FileHelper
gdcm::FileHelper *fileH = gdcm::FileHelper::New(file);
// depending on what you did before!
//--> Set the compression type :
- fileH->SetWriteTypeToJPEG(); // lossles compression
- fileH->SetWriteTypeToJPEG2000(); // lossles compression
+ fileH->SetWriteTypeToJPEG(); // lossless compression
+ fileH->SetWriteTypeToJPEG2000(); // lossless compression
fileH->SetWriteTypeToDcmExplVR(); // Explicit Value Representation (no compression)
fileH->SetWriteTypeToDcmImplVR(); // Implicit Value Representation (no compression)
// It doesn't change the values. )
// or
fileH->SetUserData((unsigned char *)imageData,size); // performs compression, when required
-
+ // ( Casting as 'unsigned char *' is just to avoid warnings.
+ // It doesn't change the values. )
+
//-> Write !
fileH->Write(fileName.str());
//This works for a single image (singleframe or multiframe)
2-1-1-1) Deal with optional DataElements // TODO : finish it
+
Any Data Element may be added (it's up to the user to understand what he is doing!)
The supplied methods 'InsertXxx' will create the DataElement or replace it if it already exists.
Have a look at gdcm/Dict/dicomV3.dic to see what are the various DICOM fields, with their VR.
// gdcm::FileHelper::CheckMandatoryElements() will check inconsistencies,
// as far as it knows how.
// Sorry, not yet available under Python.
- //vtkSetMacro(GdcmFile, gdcm::File *);
+
+ vtkSetMacro(GdcmFile, gdcm::File *);
void vtkGdcmWriter::SetGdcmFile(gdcm::File *);
void vtkGdcmWriter::SetContentTypeToUserCreatedImage()
vtkGdcmWriter::void SetContentTypeToUnmodifiedPixelsImage()
- // depending on what he did before!
+ // depending on what he did before (see C++ part)