how to put two images/frames into one dicom image

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
snie
Posts: 11
Joined: Tue, 2007-01-30, 20:50

how to put two images/frames into one dicom image

#1 Post by snie »

Hello, My fellow DCMTK developers:

I have some question on DCMTK and wish I can get some answers from you.

First of all, I am able to load a RGB image and convert and save it to dicom image at my local disk by using

dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelLength);

OFCondition status = fileformat.saveFile("qqq.dcm", EXS_LittleEndianExplicit);

But
1) How do I know if this dicom image is compressed and in what compression format, is any tag associated with it? how to control the compression rate and how to save it without compress?


2) If I want to load another image of the same resolution and adding to the same dicom image so that one dicom image have two frames, how can I accomplish?

3) One type of image I load is RGB image with 16 bits at each R, G, B channel, Can I convert this image and save it as dicom image without loss any RGB information? Do you any software can view color dicom image with 16 bits at each R, G, B channel so that I can test my code.

4) If I compress my RGB image to tiff format within memory, and then copy the compressed tiff data to pixel data, then save it as done before. It means that the original image may compressed two times. Can this result be viewed by a dicom image viewer?

5) If I have annotated RGB image (say, annotaed by PhotoShop as creating several binary layers and drawing curves/regions on those layers, adding some texts in a layer, saving layer images with the original image all together). How to convert this annotated multi-layer tiff image into dicom using DCMTK?

Thanks for your help,


snie
________
Xj13
________
ESTOQUE
Last edited by snie on Thu, 2011-02-17, 21:48, edited 2 times in total.

Michael Onken
DCMTK Developer
Posts: 2055
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: how to put two images/frames into one dicom image

#2 Post by Michael Onken »

snie wrote:Hello, My fellow DCMTK developers:

First of all, I am able to load a RGB image and convert and save it to dicom image at my local disk by using

dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelLength);

OFCondition status = fileformat.saveFile("qqq.dcm", EXS_LittleEndianExplicit);

But
1) How do I know if this dicom image is compressed and in what compression format, is any tag associated with it? how to control the compression rate and how to save it without compress?
The compression format used is "coded" in DICOM using a specific Transfer Syntax. Above, you saved your image as Little Endian Explicit, which means that you are using an uncompressed image format. By the way, you always have to alter other attributes when inserting Pixel Data into a DICOM file, e. g. Row, Columns, Bits Allocated, etc. which tells a DICOM reader about image dimensions and bit depth etc. Please take a look at the Image Pixel module in part 3 of the standard.

The compression issues in DICOM are discussed in part 5 of the standard (read about Transfer Syntaxes). You have the opportunity to use various JPEG codecs (lossy, lossless, JPEG-LS, JPEG2000, ...), RLE compression, ... The compression rate is only controlled by the encoder that is used to compress the image data that is put into the DICOM object - so the compression rate is not DICOM specific but depends on the encoder you use. There is an optional(?) attribute "Compression Rate" that you might set for saving such information to the DICOM header but you haven't to.
snie wrote: 2) If I want to load another image of the same resolution and adding to the same dicom image so that one dicom image have two frames, how can I accomplish?
This depends on whether you use an uncompressed or compressed format. Please refer to the Image Pixel module and part 5 of the standard. For uncompressed frames, you just have to put frame after frame inside the attribute pixel data. A DICOM reader knows how many bytes belong to each frame due to the image dimensions saved to the other attributes (rows, columns, ...)
snie wrote: 3) One type of image I load is RGB image with 16 bits at each R, G, B channel, Can I convert this image and save it as dicom image without loss any RGB information? Do you any software can view color dicom image with 16 bits at each R, G, B channel so that I can test my code.
You can save uncompressed RGB pixel data in DICOM without any loss of information. You can save 16bit (or even more) per component for uncompressed images.
snie wrote: 4) If I compress my RGB image to tiff format within memory, and then copy the compressed tiff data to pixel data, then save it as done before. It means that the original image may compressed two times. Can this result be viewed by a dicom image viewer?
No. The transfer syntax describes the compression format used for the pixel data. There always can only be one transfer sytanx per "file". Of course you can convert between transfer syntaxes, but there is no way describing a "double compression". By the way, there is no transfer syntax for saving compressed TIFF in DICOM. There is a trick putting a TIFF header into the DICOM preamble and referencing TIFF pixel data from there that can be put at the very end of the DICOM file. But this is seldomly used and not the thing you want to do.
snie wrote: 5) If I have annotated RGB image (say, annotaed by PhotoShop as creating several binary layers and drawing curves/regions on those layers, adding some texts in a layer, saving layer images with the original image all together). How to convert this annotated multi-layer tiff image into dicom using DCMTK?
This seems to be the only DCMTK related question :-) No, DICOM does not allow saving any propietary Photoshop or whatever formats as DICOM and so doesn't DCMTK. For annotations etc. DICOM defines so called Presentation States to save text, polygons etc. for an image. DCMTK contains a library for dealing with presentation states - take a look at the module "dcmpstat" or the DICOMscope viewer that works on top of this library.

Regards,
Michael
Thanks for your help,

snie
Posts: 11
Joined: Tue, 2007-01-30, 20:50

#3 Post by snie »

As for Compression Rate,
Do you mean
#define DCM_LossyImageCompressionRatio DcmTagKey(0x0028, 0x2112)


Also, you have defined a lot of (whole) attributes in dcdeftag.h, where to find the corresponding possible values which assign to those tags?

On the other hand, you have defined all UIDs in dcuid.h, how to use them?

By the way, can you tell me what are the standard, required tags that I have to insert into the dicom header?

Thanks,

snie
________
Mflb
________
VOLCANO VAPORIZERS
Last edited by snie on Thu, 2011-02-17, 21:48, edited 2 times in total.

Michael Onken
DCMTK Developer
Posts: 2055
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken »

snie wrote:As for Compression Rate,
Do you mean
#define DCM_LossyImageCompressionRatio DcmTagKey(0x0028, 0x2112)
Yes.
snie wrote: Also, you have defined a lot of (whole) attributes in dcdeftag.h, where to find the corresponding possible values which assign to those tags?
More than that, there should be a definition for *every* attribute defined in DICOM part 6 (I think last update 2004 from us). This is for convenience and readability of coding. There are lots of examples in the code, e. g. in the demo applications in each module's apps directory. An easy example also is provided in the API documentation:
http://support.dcmtk.org/docs/mod_dcmdata.html
snie wrote: On the other hand, you have defined all UIDs in dcuid.h, how to use them?
Hm. See last and next question.
snie wrote: By the way, can you tell me what are the standard, required tags that I have to insert into the dicom header?
The DICOM standard is about 3000 pages, including ca. 1000 pages in part 3 which contains information which attribute should be put in which DICOM object. I can't summarize this for you, I am sorry. Perhaps you should try to learn some DICOM basics about data structures (mainly part 3) and general concepts of DICOM. Some hints and sources can be found in the medical image faq provided by David Clunie : http://www.dclunie.com/medical-image-faq/html/

Regards,
Michael

snie
Posts: 11
Joined: Tue, 2007-01-30, 20:50

#5 Post by snie »

Thank you very much. I really appreciate it. I am reading Parts 3, 5, 6 now. You answers help me a lot in underdtanding those long documents.

From your answer, it indicates that

1) If I want to annote an image, I should annotate it based on dicom image using some dicom software.

2) Even I independently (not relying on dicom) develop a software to annotate a RGB image by myself (not using Photo Shop), save this multilayer RGB image and then convert this muti-layer RGB image to dicom image, a regular dicom viewer maynot be able to display as multi-layer image by dicom view.

Let me know if I am correct.


One more question:

The information on the tag: 0040,A124 is associated with UID (#define DCM_UID DcmTagKey(0x0040, 0xa124)

And the dicom header information for my dicom image is listed as

0040,A124,?=1.2.840.10008.5.1.4.1.1.7.4.

Can I replace the question mark (?) above by a string like "UID", so that it looks similar as other tags, such as

7FE0,0010,Pixel Data=15116544


Thanks,

SNIE
________
Honda P50 specifications
________
ALASKA DISPENSARY
Last edited by snie on Thu, 2011-02-17, 21:49, edited 2 times in total.

Michael Onken
DCMTK Developer
Posts: 2055
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#6 Post by Michael Onken »

Hi Snie,
snie wrote:Thank you very much. I really appreciate it. I am reading Parts 3, 5, 6 now. You answers help me a lot in underdtanding those long documents.
It's not easy to get an introduction to DICOM by reading the standard, perhaps you could start with the DICOM cookbook e.g., linked here:
http://www.medical.philips.com/main/com ... nectivity/
snie wrote: 1) If I want to annote an image, I should annotate it based on dicom image using some dicom software.
Yes. This allows for saving your annotation directly in DICOM format and will not destroy the original image by "burning" text or something similar into the image.
snie wrote: 2) Even I independently (not relying on dicom) develop a software to annotate a RGB image by myself (not using Photo Shop), save this multilayer RGB image and then convert this muti-layer RGB image to dicom image, a regular dicom viewer maynot be able to display as multi-layer image by dicom view.
Let me know if I am correct.
You are :) DICOM does not define mechanisms to save multiple RGB layers into the RGB image information of one DICOM image object.
DICOM defines so-called presentation states which can be used to add visual layers to an image for presentation. A presentatation state is saved into an extra object that only references the original image. The former stays unchanged. You would have to "convert" your multi-layer image into one DICOM image with one or more presentation states - which in most cases should be difficult.
snie wrote: #define DCM_UID DcmTagKey(0x0040, 0xa124)
0040,A124,?=1.2.840.10008.5.1.4.1.1.7.4.
Can I replace the question mark (?) above by a string like "UID", so that it looks similar as other tags, such as

7FE0,0010,Pixel Data=15116544
Do you refer to the dcmdump output? Tag names are not transfered (saved) in a DICOM object but only the tag (0x0040,0xA124). So every DICOM application has to look up the tag name in a local "DICOM dictionary". In DCMTK, the UID tag you talk of is treated the same way as all other tags found in the dictionary (dicom.dic). So dcmdump for example should print "UID" (the name of the tag) and not "?", because the tag is defined dicom.dic. The #define you mentioned above is only a help for programmers that can actually write DCM_UID instead of 0x0010,0x0010. The translation into the tag name is done in dicom.dic, respectively in dcdict.zz, which is generated from this file. Another application may have its own dictionary which might not contain the 0x0040,0xA124 tag. This could be the reason for the "?".

Regards,
Michael

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 1 guest