reading pixel data from a file without loading it into memory

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
NasibehHassanjani
Posts: 3
Joined: Mon, 2020-12-14, 16:46

reading pixel data from a file without loading it into memory

#1 Post by NasibehHassanjani » Mon, 2021-01-18, 09:39

I heard that there is a method to set pixel data from a file without loading it into memory. I also found "createValueFromTempFile" method which seems to serve this purpose.
It seems to me that with this method we set the "fileName" and later when we want to save it to a Dicom file it will read from a given "fileName". But I am not sure if I get it correctly.

This is the pseudo-code I use:

//create a DICOMobject ...

Code: Select all

DcmInputFileStream fileStream(fileName, offset);
DcmPixelData pixelData(DcmTag(TAG_PixelData.GetGroup(), TAG_PixelData.GetElement()), length);
pixelData.createValueFromTempFile(fileStream.newFactory(), length, byteOrder);
m_DcmDataSet->insert(&pixelData);
// save it to dicomfile

The result dose not seem to be Dicom valid. I would appreciate any hint.

NasibehHassanjani
Posts: 3
Joined: Mon, 2020-12-14, 16:46

Re: reading pixel data from a file without loading it into memory

#2 Post by NasibehHassanjani » Mon, 2021-01-18, 16:53

I found what was the problem. The code should be as follow

Code: Select all

DcmInputFileStream fileStream(fileName, offset);
DcmElement *elem = NULL;
elem = new DcmPixelData(DcmTag(TAG_PixelData.GetGroup(), TAG_PixelData.GetElement()));
elem.createValueFromTempFile(fileStream.newFactory(), length, byteOrder);
m_DcmDataSet->insert(elem, true);

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest