getOutputData returns 0 for compressed image. Why?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ddt
Posts: 2
Joined: Wed, 2006-03-15, 15:35

getOutputData returns 0 for compressed image. Why?

#1 Post by ddt »

I want to view image data from DICOM file. I have DICOM file that contains JPEG grayscale(or color) image. The DicomImage::getOutputData returns 0, why? However if I have uncompressed image all is OK.

Colby Dillion
Posts: 13
Joined: Tue, 2005-06-28, 16:48

#2 Post by Colby Dillion »

Did you register the JPEG codecs before trying to load the file? Have you checked DicomImage::getStatus()? Just for grins try this code if that doesn't get you somewhere.

Code: Select all

//-------------------------------------------------------------------------------------------------
// DCMTK Includes
//-------------------------------------------------------------------------------------------------
#include "dcmtk/config/osconfig.h"

#define INCLUDE_CSTDIO
#define INCLUDE_CSTRING
#include "dcmtk/ofstd/ofstdinc.h"

#include "dcmtk/dcmdata/dctk.h"			/* for various dcmdata headers */
#include "dcmtk/dcmdata/dcdebug.h"		/* for SetDebugLevel */
#include "dcmtk/dcmimgle/dcmimage.h"	/* for DicomImage */
#include "dcmtk/dcmimage/diregist.h"	/* include to support color images */
#include "dcmtk/dcmdata/dcrledrg.h"		/* for DcmRLEDecoderRegistration */
#include "dcmtk/dcmjpeg/djdecode.h"		/* for dcmjpeg decoders */
#include "dcmtk/dcmjpeg/dipijpeg.h"		/* for dcmimage JPEG plugin */

//-------------------------------------------------------------------------------------------------
// Main
//-------------------------------------------------------------------------------------------------
int main(int argc, char* argv[]) {
	DcmRLEDecoderRegistration::registerCodecs();
	DJDecoderRegistration::registerCodecs();

	DcmFileFormat file;
	OFCondition status = file.loadFile("C:\\dicom\\test.dcm");
	if (status.good()){
		DicomImage image(file.getDataset(), EXS_Unknown);
		// or DicomImage image("C:\\dicom\\test.dcm");
		if (image.getStatus() == EIS_Normal) {
			image.setMinMaxWindow();
			image.writeBMP("C:\\dicom\\test.bmp", 24);
		}

		OFString patientsName;
		if (file.getDataset()->findAndGetOFString(DCM_PatientsName, patientsName).good()) {
		  cout << "Patient's Name: " << patientsName << endl;
		} else
		  cerr << "Error: cannot access Patient's Name!" << endl;
	} else
		cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
	return 0;
}

MicroFace
Posts: 15
Joined: Thu, 2005-10-27, 21:46

#3 Post by MicroFace »

Thank you for this wonderful and instructive example.
I will treasure it always.

Post Reply

Who is online

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