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 !
how to calculate the Haunsfield Unit data value!
Moderator: Moderator Team
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
As you can read in the documentation, the modality transformation is already applied to the "intermediate representation".
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!
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!
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Who is online
Users browsing this forum: Bing [Bot] and 1 guest