file size got reduced

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
George
Posts: 52
Joined: Sun, 2023-11-12, 16:50

file size got reduced

#1 Post by George »

Hello,

I am using the below code but its seems that the moment I try to save the pixel all the pixel data get lost and the file size get reeduced, any chance that the saveFile function
did cause this loss, if yes how can I prevent them

Code: Select all

OFCondition status = fileformat.loadFile(dicomFilename.c_str());
if (!status.good()) {
      std::cerr << "Error: Cannot load DICOM file: " << dicomFilename << std::endl;
      return;
}

// Get the dataset from the loaded DICOM file
DcmDataset* dataset = fileformat.getDataset();

 E_TransferSyntax transferSyntax = EXS_LittleEndianImplicit;
 status = fileformat.saveFile(dicomFilename.c_str(), transferSyntax);
 if (!status.good())
 {
     std::cerr << "Error: Cannot save updated DICOM file: " << dicomFilename << std::endl;
     return;
 }
 

J. Riesmeier
DCMTK Developer
Posts: 2506
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: file size got reduced

#2 Post by J. Riesmeier »

Large element values like Pixel Data are only loaded on demand, i.e. if you write to the same filename, the Pixel Data has not been loaded yet from the input file and is, therefore, stored with 0 byte length to the output file.

One solution is to use different filenames for input and output file. Another solution is to load the Pixel Data into main memory before calling saveFile(). The latter is done by calling loadAllDataIntoMemory() on the dataset.
Alternatively, you could specify a larger value for the "maxReadLength" parameter of the loadFile() method, i.e. a value that is larger than the length of the Pixel Data element.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest