how to calculate the Haunsfield Unit data value!

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
msn123321
Posts: 2
Joined: Wed, 2007-12-19, 03:58

how to calculate the Haunsfield Unit data value!

#1 Post by msn123321 »

hi ,all!
I have problems to calculate the Haunsfield Unit data value(ct-value),I have read some codes about the dcmtk sdk;and i wrote the codes as follows, but the result seems to be not right.

So,I need your help!

//get the Haunsfield Unit data value

int GetHounsField(CPoint ptImage)
{
int iPos = ptImage.x * ptImage.y;
long slope = 0, intercept = 0;
OFString str;

//get the slope
if ((m_dcmfile.getDataset())->findAndGetOFString(DCM_RescaleSlope,str).bad())
{
return;
}
slope = atol(str.data());

//get the intercept
if (m_dcmfile.getDataset()->findAndGetOFString(DCM_RescaleIntercept,str).bad())
{
return;
}
intercept = atol(str.data());

//m_dcmfile is a object of DcmFileFormat ;
DicomImage diImag(m_dcmfile.getDataset(),EXS_Unknown);
const DiPixel *dmp = NULL;
dmp = diImag.getInterData ();
if (NULL == dmp)
{
return 0;
}
void *pixelData = NULL ;

pixelData = (void *)dmp->getData();

if (NULL == pixelData)
{
return 0;
}
EP_Representation er_rep = dmp->getRepresentation();
int result = 0;
switch(er_rep)
{
case EPR_Sint16:
{
Sint16 *pixelNew1 = ((Sint16*)pixelData+iPos);
result = (((*pixelNew1) * slope)+intercept);
break;
}

case EPR_Uint16:
{
Uint16 *pixelNew2 = ((Uint16*)pixelData+iPos);
result = (((*pixelNew2) * slope)+intercept);
break;
}

default:
{
Sint8 *pixelNew3 = ((Sint8*)pixelData+iPos);
result = (((*pixelNew3) * slope)+intercept);
break;
}

}
return result;
}

Thank you !

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

As you can read in the documentation, the modality transformation is already applied to the "intermediate representation".

msn123321
Posts: 2
Joined: Wed, 2007-12-19, 03:58

#3 Post by msn123321 »

Dear Jörg,

Thanks for the reply.


In the debug mode,
it goes into the lines of case EPR_Sint16: ,
and intercept = -1024, the value of slope is 1 ;
the value of result is -2021,

And I test it with other software ,but the result is different,
Maybe there is somethings wrong with my codes !

Thanks and regards!

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

What I wanted to say in my last posting: You are applying the modality transformation twice (since it is already applied by the DicomImage constructor)!

alwittta
Posts: 111
Joined: Wed, 2006-03-15, 08:30

#5 Post by alwittta »

Dear Jörg,

I would like to know , if the DicomImage class object contains the object with already applied Window width and level, then without applying the modality transformation, the above calculation for Haunsfield Unit is correct?

Thanks and regards
Alvin

Horex
Posts: 1
Joined: Fri, 2009-01-09, 10:42

#6 Post by Horex »

Hi, I have seen your code and this funktion will be very interesting for me! Unfotunately I'am not knowing, what's the two parameters which are needed to commit the funktion. Could you please tell me, how I could manage this?

Thanks a lot
Horex

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest