Interpreting Overlay Data

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
michalp
Posts: 6
Joined: Mon, 2018-07-09, 14:11

Interpreting Overlay Data

#1 Post by michalp »

Hello,

I have a few questions regarding Overlays in DCMTK. Class DicomImage provides a few functions for reading Overlays. My goal is to render an image of an Overlay (it might be in any format, i.e. bmp).

I'm using internal library for creating image objects for further rendering. I cannot say much about this library, but it's main function takes following parameters: width, height, channels, colorspace, and I'm just copying (width * height) bytes from buffer pointed by dcmImage->getFullOverlayData(0, width, height) to Image object provided by library. This approach works for manually reading images from PixelData tag.

Unfortunately, overlay image rendered that way is distorted and looks as follows:

Image

The original image looks like this:

Image


Could you please point me to the right direction? How to interpret data obtained from getFullOverlayData?


Another note:
I did some experiments with OverlayData (grp number 6000, so just a 'plane 0'). Whenever I read tag value of OverlayData as string and print it, i receive a string in format

"ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\
\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\ffff\f\
fff\ffff\ffff\ffff\fffe\ffff"

which suggests, that each pixel is represented by 2 bytes (4 hexadecimal digits), but VR of "OverlayData" is "OB".

I have printed first K pixels of getFullOverlayData buffer (in C++, firstly casting buffer to uint_16*, and then by casting *(buffer + index) value to int) and it differs from the values represented by mentioned above string (the one readed from OverlayData as string).


Edit:

Another questions:

1. DICOM documentation states, that VR of OverlayData is "OB or OW", but reading VR name of OverlayData in DCMTK returns "OB" (I use DcmTag.getVR().gerValidVRName()).
2. Reading normal 2D Images via DCMTK and my internal library works correctly, but whenever I want to render image with Overlays by using DicomImage->showAllOverlays() function, the overlays rendered are also distorted (in the same way, as on image above).


Apologies for chaos in this post and thank you in advance for response,
Michal

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Interpreting Overlay Data

#2 Post by J. Riesmeier »

Could you please point me to the right direction? How to interpret data obtained from getFullOverlayData?
Short answer: This depends on the value of the "bits" parameter. The default value is 8, i.e. you get an array of 8 bit values having the two colors/values "fore" and "back".

michalp
Posts: 6
Joined: Mon, 2018-07-09, 14:11

Re: Interpreting Overlay Data

#3 Post by michalp »

Thank you for quick response.
Short answer: This depends on the value of the "bits" parameter. The default value is 8, i.e. you get an array of 8 bit values having the two colors/values "fore" and "back".
I do memcpy from getFullOverlayData buffor with 'bits' parameter set to default 8. Image object from my library uses uint8_t as underlying pixel data type. It is expected then, that every pixel will be copied correctly, which is not the case (as rendered image is distorted).

Let's have an example:

auto b = dicomImage->getFullOverlayData(0, width, height);

In this case, first 2 bytes of b describe first 2 pixels of overlay, am I correct?

---

Another thing. Shouldn't "showAllOverlays" function display overlays correctly? Whenever I render Image readed from dcmtk by creating DicomImage object, I obtain correct image from DICOM file. I wanted to also display overlays for that image, but calling dicomImage->showAllOverlays() function also results in distorted overlay rendered on image. Here is how it looks:

Image

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Interpreting Overlay Data

#4 Post by J. Riesmeier »

Are you sure that the OverlayData is encoded correctly in your sample DICOM image?

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest