How to release compressed pixel data from DcmDataset?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
abhishek_gupta
Posts: 12
Joined: Fri, 2010-06-18, 06:14

How to release compressed pixel data from DcmDataset?

#1 Post by abhishek_gupta »

Hello Group members, I am working in loading compressed DICOM file as received from from a remote server using below code.
I want to do two things here:
1. Free/release compressed pixel data after decompression.
2. Is there a way of creating DcmFileformat OR DcmDataset without compressed pixel data allocation.

Code: Select all

        /* Load compressed DICOM data from network's char* data stream */
        DcmInputBufferStream DibStream;
	DibStream.setBuffer(buffer, bufferLen);
	DibStream.setEos();
	OFCondition loadStatus = this->file_format.read(DibStream);

       /* Uncompress using DicomImage class*/
       DicomImage * dicomImage = new DicomImage(&file_format, file_format.getDataset()->getOriginalXfer()  , CIF_UsePartialAccessToPixelData | CIF_DecompressCompletePixelData, 0, 0);

       /* store uncompressed pixel data in local variable and delete DicomImage reference */
       
       /* some more code here ... */
       delete dicomImage

      /* [b]Note: DcmFileformat::file_format is allocated on stack and is cleared on this class's destructor.[/b]*/

Thank you
Abhishek Gupta.

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

Re: How to release compressed pixel data from DcmDataset?

#2 Post by J. Riesmeier »

Regarding your first question, the following method (from DcmDataset or DcmFileFormat) might provide what you want:

Code: Select all

    /** removes all but the current representation and sets the original
     *  representation to current
     */
    void removeAllButCurrentRepresentations();
Regarding your second question, what do you mean by that? Could you please describe in more detail what the background of your question is.

By the way, why do you use the DicomImage class for decompressing the pixel data? This class is intended to be used for rendering images, i.e. for visualization purposes.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest