All other questions regarding DCMTK
Moderator: Moderator Team
Mercusyo
Posts: 34 Joined: Mon, 2011-10-31, 15:22
#1
Post
by Mercusyo » Tue, 2014-05-27, 15:29
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
Anyone can help me please ?
Thanks!
Best regards,
J. Riesmeier
DCMTK Developer
Posts: 2506 Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:
#2
Post
by J. Riesmeier » Tue, 2014-05-27, 16:39
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
#3
Post
by Mercusyo » Wed, 2014-05-28, 07:42
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: 2506 Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:
#4
Post
by J. Riesmeier » Wed, 2014-05-28, 08:47
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
#5
Post
by Mercusyo » Wed, 2014-05-28, 09:05
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: 2506 Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:
#6
Post
by J. Riesmeier » Wed, 2014-05-28, 09:11
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
#7
Post
by Mercusyo » Tue, 2014-06-03, 12:42
Ok, thank you for your great help
My program works fine now
Mercusyo
Posts: 34 Joined: Mon, 2011-10-31, 15:22
#8
Post
by Mercusyo » Tue, 2014-06-03, 14:23
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: 2506 Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:
#9
Post
by J. Riesmeier » Thu, 2014-06-12, 08:51
The dcmimgle/dcmimage module does not "see" compressed pixel data, because decompression in done by dcmdata. Also see my answer to your other posting.
Users browsing this forum: Bing [Bot] , Google [Bot] and 1 guest