Examples using getInterData()
Moderator: Moderator Team
Examples using getInterData()
I'm trying to construct a program that uses DicomImage::getInterData() to access the pixel data. However, the getCount() method of the DiPixel object I get from it always seems to return 0. Could someone point me to a working example of how to use the new getInterData() method, please?
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Did you check whether the image could be loaded at all?
Here's a little sample program that works for me:
Here's a little sample program that works for me:
Code: Select all
// test program for DicomImage::getInterData()
// -- requires DCMTK version 3.5.4
// -- works for monochrome images only
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmimgle/dcmimage.h"
int main(int argc, char *argv[])
{
if (argc > 1)
{
DicomImage image(argv[1]);
if (image.getStatus() == EIS_Normal)
{
const DiPixel *inter = image.getInterData();
if (inter != NULL)
{
COUT << "number of bytes: " << inter->getCount() << endl;
}
} else
CERR << "cannot load file: " << argv[1] << endl;
}
return 0;
}
Examples using getInterData()
Thanks! That did it. Here's a version that supports compressed and color images as well, in case someone is interested:
Code: Select all
// test program for DicomImage::getInterData()
// -- requires DCMTK version 3.5.4
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmimgle/dcmimage.h"
#include "dcmtk/dcmimage/diregist.h" // Support for color images
#include "dcmtk/dcmdata/dcrledrg.h" // Support for RLE images
#include "dcmtk/dcmjpeg/djdecode.h" // Support for JPEG images
class DicomCodecRegistration
{
public:
DicomCodecRegistration(void)
{
// register decompression codecs
DcmRLEDecoderRegistration::registerCodecs();
DJDecoderRegistration::registerCodecs();
}
~DicomCodecRegistration(void)
{
// deregister decompression codecs
DcmRLEDecoderRegistration::cleanup();
DJDecoderRegistration::cleanup();
}
};
int main(int argc, char *argv[])
{
DicomCodecRegistration registerCodecs;
if (argc > 1)
{
DicomImage image(argv[1]);
if (image.getStatus() == EIS_Normal)
{
const DiPixel *pixeldata = image.getInterData();
if (pixeldata != NULL)
{
COUT << "number of pixels: " << pixeldata->getCount() << endl;
}
} else
CERR << "cannot load file: " << argv[1] << endl;
}
return 0;
}
Who is online
Users browsing this forum: No registered users and 1 guest