1
votes

I am currently using DCMTK in C++. I am quite new to this toolkit but, as I understand it, I should be able to read the window centre and width for normalisation purposes.

I have a DicomImage DCM_image object with my Dicom data. I read the values to an opencv Mat object. However, I now would like to normalise them. The following shows how I am reading and transferring the Data to an opencv Mat.

    DicomImage DCM_image("test.dcm");
    uchar *pixelData = (uchar *)(DCM_image.getOutputData(8));   
    cv::Mat image(int(DCM_image.getHeight()), int(DCM_image.getWidth()), CV_8U, pixelData);

Any help is appreciated. Thanks

1

1 Answers

1
votes

Reading window center and width is not difficult, however you need to use a different constructor and pass a DcmDataset to the image.

DcmFileFormat file;
file.loadFile("test.dcm");
DcmDataset* dataset = file.getDataset()
DicomImage image(dataset);
double windowCenter, windowWidth;
dataset->findAndGetFloat64(DcmTagKey(0x0010, 0x1050), windowCenter);
dataset->findAndGetFloat64(DcmTagKey(0x0010, 0x1051), windowWidth);

But actually I do not think it is a good idea to apply the windowing to the image upon loading. Windowing is something which should be adjustable by the user. The attributes Window Center and Window Width allow multiple values which can be applied to adjust the window to the grayscale range of interest ("VOI", Values of Interest).

If you really just want to create a windowed image, you can use your code to construct the image from the file contents and use one of the createXXXImage methods that the DicomImage provides.

HTH