I am trying to use the DCMTK API to read some dicom files. The following piece of code works when the Pixel Representation value is 0 (uncompressed image, as I understand). However, when I am trying to read an image with pixel representation value 1, I get an error: Pixel representation cannot be changed
Code: Select all
auto dcm_ff = DcmFileFormat();
dcm_ff.loadFile("/mnt/hdd8/axle/dev/dcmtk_reader/data/pydicom-data/data/693_J2KR.dcm");
auto dcm_tag_pixel_data = DcmTagKey(0x7fe0,0x0010) ;
DcmElement* pixel_data_ptr = nullptr;
auto stat = dcm_ff.getDataset()->findAndGetElement(DCM_PixelData, pixel_data_ptr);
DcmPixelData* pixel_data = OFreinterpret_cast(DcmPixelData*, pixel_data_ptr);
std::cout << stat.text() << std::endl;
uint32_t frame_size = 0;
pixel_data->getUncompressedFrameSize(dcm_ff.getDataset(),frame_size);
frame_size % 2 == 0 ? frame_size = frame_size : frame_size = frame_size + 1;
auto buffer = std::vector<uint16_t>(frame_size);
uint32_t start_fragment = 0;
OFString decompressed_color_model;
uint32_t frame_no = 0;
auto status = pixel_data->getUncompressedFrame(dcm_ff.getDataset(),
frame_no,
start_fragment,
buffer.data(),
frame_size,
decompressed_color_model, NULL);
std::cout << status.text()<<std::endl;
Can anyone please tell me what should I do differently to read images with pixel representation value of 1?