Here's an example that shows how it works in principle:
#include "dcmtk/config/osconfig.h" #include "dcmtk/dcmimgle/dcmimage.h" int main(int argc, char *argv[]) { DicomImageClass::setDebugLevel(0xff); DicomImage img("overlay_image.dcm"); if (img.getStatus() == EIS_Normal) { #ifdef EXPORT_FULL_OVERLAY unsigned int width, height; /* create bitmap (1 bit) for first overlay plane */ Uint8 *data = (Uint8 *)img.getFullOverlayData(0, width, height, 0, 1, 0, 1); const size_t size = (size_t)((width * height + 7) / 8); #else unsigned int left, top, width, height; EM_Overlay mode; /* create bitmap (8 bit) for first overlay plane, cropped to image size */ Uint8 *data = (Uint8 *)img.getOverlayData(0, left, top, width, height, mode); const size_t size = (size_t)(width * height); #endif if (data != NULL) { COUT << "overlay: " << width << " / " << height << OFendl; /* write overlay data (bitmap) to a file */ FILE *file = fopen("overlay.raw", "wb"); if (file != NULL) { fwrite(data, size, 1, file); fclose(file); } } else CERR << "no such overlay plane" << OFendl; } return 0; }
Discussion