Automate DICOM file generation

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Silvermaul
Posts: 31
Joined: Thu, 2010-09-02, 10:03

Automate DICOM file generation

#1 Post by Silvermaul »

Hello all fellow members,

my current task is to achieve the automation of dicom file generation. To do this I have a "base" file and from it I generated files with different tags/images and so on. While changing the tags is trivial, I have some questions regarding the images.

For the simplest of all cases lets say that I would like to manually change the brightness of all frames in a DICOM file.

While using something like this:

//my file has 397 frames
Uint8 *pixelData = (Uint8 *)(image->getOutputData(8,396 /*From 0 to 396*/));
for(int i=0;i<rows*columns;++i)
{
//do something here
}

seem to work, I don't see a way to save the processed pixels back to the file.

For this reason I assume that using:

Code: Select all

							const unsigned char* myPixelData;
							unsigned long Count;
							dataset->findAndGetUint8Array(DCM_PixelData, myPixelData,&Count);
should be preferred. And after processing a new unsigned char array should be inserted with putAndInsertUint8Array..

My questions are these:

Are there differences between these pixel values and the values from getOutputData() method?

I fail to realise what the variable Count , counts exactly.

Shouldn't the length of the pixel Array acquired from findAndGetUint8Array
be the same as = rows*columns*frames?

Sorry if I am not understanding something but I am a complete newbie with DICOM and dcmtk libs! Thanks for your help!

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

I don't see a way to save the processed pixels back to the file.
As you can read in the documentation of the main interface class DicomImage, this class/module is intended for visualization and not for the creation of DICOM images. Nevertheless, there are some helper functions that allows for writing back the internally stored pixel data (and related attributes) to a DICOM image. See writeImageToDataset() and writeFrameToDataset().
Are there differences between these pixel values and the values from getOutputData() method?
In principle no, but in practice this depends, of cource, on the value of the describing elements from the Image Pixel Module (e.g. BitsStored, BitsAllocated, etc.)
I fail to realise what the variable Count , counts exactly.
I thought, this is clear from the API documentation. "Count" refers to the number of elements in the array, i.e. number of bytes for findAndGetUint8Array().
Shouldn't the length of the pixel Array acquired from findAndGetUint8Array be the same as = rows*columns*frames?
This may be the case (depending on what you mean by "length"), but this again depends on the value of the describing elements like BitsAllocated. Please remember that the PixelData element (in case of uncompressed transfer syntax) is just a sequence of 8 (OB) or 16 bit (OW) values. Read the relevant sections of part 3 and 5 if needed ...

Silvermaul
Posts: 31
Joined: Thu, 2010-09-02, 10:03

#3 Post by Silvermaul »

Thanks for the info. I better start reading :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest