Using getInterData

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Mercusyo
Posts: 34
Joined: Mon, 2011-10-31, 15:22

Using getInterData

#1 Post by Mercusyo »

Hello,

I would like to read the "real" pixel data and I used the method "getInterData" of "DicomImage class"

I created 2 methods like :

Code: Select all

bool getInternalPixelData(const char* filename, unsigned short* value)
{
	bool isResult = false;
	// Récupération des données de l'image
	int nbFrame = 1;
	unsigned long NbByte = 0;
	unsigned short* pixelData = NULL;
	DicomImage* img = new DicomImage(filename);
	if (img->getStatus() == EIS_Normal)
	{
		const DiPixel *inter = img->getInterData();
        if (inter != NULL)
        {
			NbByte = inter->getCount();
			if (NbByte > 0)
			{
				pixelData = (unsigned short*)inter->getData();
				if (pixelData != NULL)
				{
					for (unsigned long i = 0; i < NbByte; i++)
					{
						value[i] = pixelData[i];
					}
					if (value != NULL)
						isResult = true;
				}
			}
        }
	}
	free(pixelData);
	return isResult;
}
and

Code: Select all

bool getInternalSignedPixelData(const char* filename, short* value)
{
	bool isResult = true;
	// Récupération des données de l'image
	int nbFrame = 1;
	unsigned long NbByte = 0;
	short* pixelData = NULL;
	DicomImage* img = new DicomImage(filename, NULL, 0, nbFrame);
	if (img->getStatus() == EIS_Normal)
	{
		const DiPixel *inter = img->getInterData();
        if (inter != NULL)
        {
			NbByte = inter->getCount();
			pixelData = (short*)inter->getData();
			if (pixelData != NULL)
			{
				for (unsigned long i = 0; i < NbByte; i++)
				{
					value[i] = pixelData[i];
				}
				if (value != NULL)
					isResult = true;
			}
        }
	}
	free(pixelData);
	return isResult;
}
This code works great with certains dicom series files; but with T2 MR dicom files, I have an access violation :shock:

Anyone can help me please ?

Thanks!

Best regards,

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Using getInterData

#2 Post by J. Riesmeier »

As you can read in the documentation of this method: "Always use DiPixel::getRepresentation() in order to determine the integer representation of the internally stored pixel data." :)

Mercusyo
Posts: 34
Joined: Mon, 2011-10-31, 15:22

Re: Using getInterData

#3 Post by Mercusyo »

Thanks for your reply. Yes, I read the documentation, but I don't understand how use this method ... with a "switch" I supposed, but how I get the right format :?:
Thanks a lot,

Best regards,

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Using getInterData

#4 Post by J. Riesmeier »

The "right format" is what is stored internally, so it's your task to interpret the stored pixel data (intermediate representation) correctly. In your sample code you always expect "unsigned short" (unsigned 16-bit integer) values, which is apparently not true for all images.

Mercusyo
Posts: 34
Joined: Mon, 2011-10-31, 15:22

Re: Using getInterData

#5 Post by Mercusyo »

Ok, thank you for your new reply. In fact, I created a DLL to interface DCMTK to my C++ Builder program. I used the "mangling" technique ...
So, I must know the format for my C++ Builder part of program ...

Best regards,

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Using getInterData

#6 Post by J. Riesmeier »

As I said, the format (data type) is given by the enum value returned by getRepresentation():

Code: Select all

** internal representation of pixel data
 */
enum EP_Representation
{
    /// unsigned 8 bit integer
    EPR_Uint8, EPR_MinUnsigned = EPR_Uint8,
    /// signed 8 bit integer
    EPR_Sint8, EPR_MinSigned = EPR_Sint8,
    /// unsigned 16 bit integer
    EPR_Uint16,
    /// signed 16 bit integer
    EPR_Sint16,
    /// unsigned 32 bit integer
    EPR_Uint32, EPR_MaxUnsigned = EPR_Uint32,
    /// signed 32 bit integer
    EPR_Sint32, EPR_MaxSigned = EPR_Sint32
};

Mercusyo
Posts: 34
Joined: Mon, 2011-10-31, 15:22

Re: Using getInterData

#7 Post by Mercusyo »

Ok, thank you for your great help :!:
My program works fine now :D

Mercusyo
Posts: 34
Joined: Mon, 2011-10-31, 15:22

Re: Using getInterData

#8 Post by Mercusyo »

I'm back to this topic. What about the getRepresentation méthod with compressed dicom files :?:
I have some troubles of violation access on it ...
Thank a lot

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Using getInterData

#9 Post by J. Riesmeier »

The dcmimgle/dcmimage module does not "see" compressed pixel data, because decompression in done by dcmdata. Also see my answer to your other posting.

Mercusyo
Posts: 34
Joined: Mon, 2011-10-31, 15:22

Re: Using getInterData

#10 Post by Mercusyo »

Ok, thank you for your help!

Post Reply

Who is online

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