I am trying to read pixel data of a frame directly to an array. I looked at some example code from diinpxt.h file but not sure where I am making the mistake. I have the following code:
Code: Select all
auto dcm_ff = DcmFileFormat();
auto dcm_tag_pixel_data = DcmTagKey(0x7fe0,0x0010) ;
dcm_ff.loadFile("/mnt/hdd8/axle/dev/dcmtk_reader/data/pydicom-data/data/eCT_Supplemental.dcm");
DcmPixelData pixel_data = DcmPixelData(dcm_tag_pixel_data);
DcmElement* pixel_data_ptr = &pixel_data;
dcm_ff.getDataset()->findAndGetElement(DCM_PixelData, pixel_data_ptr);
pixel_data.getUncompressedFrameSize(dcm_ff.getDataset(),frame_size);
frame_size % 2 == 0 ? frame_size = frame_size : frame_size = frame_size + 1; // make it even
std::cout << "Frame Size " << frame_size << std::endl;
auto buffer = new 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,
OFreinterpret_cast(Uint16 *, buffer),
frame_size,
decompressed_color_model);
std::cout << status.text()<<std::endl;
Below are some relevant tag data for the file I am working with.
Code: Select all
(0028, 0002) Samples per Pixel US: 1
(0028, 0004) Photometric Interpretation CS: 'MONOCHROME2'
(0028, 0008) Number of Frames IS: '2'
(0028, 0010) Rows US: 512
(0028, 0011) Columns US: 512
(0028, 0100) Bits Allocated US: 16
(0028, 0101) Bits Stored US: 16
(0028, 0102) High Bit US: 15
(0028, 0103) Pixel Representation US: 0
(0028, 0301) Burned In Annotation CS: 'NO'
Thanks!