get pixel data

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
candy
Posts: 24
Joined: Mon, 2008-10-20, 08:37

get pixel data

#1 Post by candy »

Hi , I have a problem which is that I want to get the pixel data in the image . There is my codes:

Code: Select all

DcmDataset *FDset =dfile->getDataset(); 
Uint8 *pixelData =NULL;
unsigned long pcount;
 OFCondition statue;
statue=FDset->findAndGetUint8Array(DCM_PixelData,pixelData,&pcount);
 cout<<pcount<<endl;
 if(statue.good())
 { 
      cout<<"statue (" << statue.text() << ")." <<endl; 
for (int counter=0; counter< pcount;counter++) { 
           cout << "pixel #" << counter << ": " << pixelData[counter]; 
}
The VR of the pixel data is OB ,and the transfer syntax is explicit VR little endian. I get nothing about pixelData[counter];It didn't display in the screen. Could you tell me what's wrong?

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1444
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#2 Post by Marco Eichelberg »

If the VR of the pixel data is OB then please check if the image is compressed (that is, the length field is set to 0xFFFFFFFF which stands for "undefined length"). In that case your code won't work - compressed pixel data has a completely different structure in DICOM.

In that case, unless you want to access the compressed bitstream, register a decoder and decompress the pixel data first - this will most probably change the VR to OW, which is the default for uncompressed DICOM.

Check dcmdjpeg.cc or dcmdrle.cc on how to register decoders for compressed pixel data.

liuxinming
Posts: 83
Joined: Thu, 2009-03-19, 04:19

#3 Post by liuxinming »

Marco Eichelberg wrote:If the VR of the pixel data is OB then please check if the image is compressed (that is, the length field is set to 0xFFFFFFFF which stands for "undefined length").
How can we get the length field? Shall we use the findAndGetOFString() method to get the transfersyntax firstly, and then look it up in dcuid.h to get the name of it?

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1444
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#4 Post by Marco Eichelberg »

Just run dcmdump against the DICOM image file.

liuxinming
Posts: 83
Joined: Thu, 2009-03-19, 04:19

#5 Post by liuxinming »

Marco Eichelberg wrote:Just run dcmdump against the DICOM image file.
Since you' ve explained how we can obtain the length field by using the dcmdump tool, there is another issue: Dcmtk offers us many small tools, such as storescp, echoscu and so on. Can I nest them into my application? For instance, if I am editing the source code on a specific platform, how can I use them in my source code lines?

Thanks a lot!

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1444
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#6 Post by Marco Eichelberg »

Most of the tools just demonstrate the capabilities of the underlying libraries, i.e. they evaluate command line options and then call a single (or few) functions of the underlying libraries. Therefore, in many cases it is rather straightforward to duplicate the functionality in your own application - read the source code of the tools, that's (at least in part) what they are intended for: as simple examples or tutorials on how to use the libraries.

Post Reply

Who is online

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