I am currently investigating how the requirements of PS3.5, Appendix A are implemented and whether we have to consider them in our code using DCMTK or if DCMTK has built-in methods doing the job.
If I got it correctly, the baseline for Little Endian Implicit/Explicit is:
- if the TS is Explicit Little Endian and the pixeldata is <= 8bpp, VR of pixel data shall be VR_OB
- in all other cases, VR of pixel data shall be VR_OW
The code below illustrates the expectations and observations. It is a minimal working example; my "problem" is in the last line (see comment). My application writes the Image Pixel Module attributes as well which are missing here. But the results are the same, and I cannot see how anything but the VR and the TS are considered when converting the TS.
Code: Select all
DcmDataset dataset;
dataset.chooseRepresentation(EXS_LittleEndianImplicit, nullptr);
std::unique_ptr<char> pixelData (new char[512*512]);
OFCondition ofResult = dataset.putAndInsertUint16Array(DCM_PixelData, reinterpret_cast<unsigned short*> (pixelData.get()), 512 * 512 / 2);
DcmElement* element;
ofResult = dataset.findAndGetElement(DCM_PixelData, element, false);
DcmEVR valueRep = element->getVR(); // -> VR_OW
dataset.chooseRepresentation(EXS_LittleEndianExplicit, nullptr);
dataset.findAndGetElement(DCM_PixelData, element, false); // should not be necessary...but just to make sure
valueRep = element->getVR(); // expected: VR_OB, actual: VR_OW