Error

# How to Calculate Hounsfield Unit

#1 Posted : Sunday, February 26, 2012 11:29:25 PM(UTC)

Groups: Registered
Posts: 43

Hi,
I want the formula for calculating Hounsfield unit which statisfying all possible image types.
Actually I am using LT from many years and some times backs (say in 2004 or 2005) I got one mail from leadtools support specifying how to calculate the Hounsfield Unit (that formula is in terms of 2's complement) but I lost the mail. Using that formula I am getting correct HU for all type of images.
Is it possible to get that one again?

#2 Posted : Monday, February 27, 2012 4:18:54 AM(UTC)

Groups: Registered, Tech Support
Posts: 179

The sample code in the following forum post shows how you can calculate the Hounsfield Unit for a pixel selected using the mouse:

The sample also contains the following notes:

If an image has RescaleSlope and RescaleIntercept values, you can use DicomGetImageFlags.AutoApplyVoiLut + DicomGetImageFlags.AutoApplyModalityLut flags when getting the image from the dataset, the pixel intensity value would be already in terms of HU.

If you want to go lower level and use the image data as it is in the dataset file, pass DicomGetImageFlags.None and then use the following equation:
HU = PixelIntensity * RescaleSlope + RescaleIntercept
Mohamed Abedallah
Developer Support Engineer

#3 Posted : Tuesday, April 23, 2013 1:44:48 AM(UTC)

Groups: Registered
Posts: 43

hi, using the sample HU calculation are correct. I want go with low level i.e. using pixelintensity ,rescaleslope and rescaleintercept.
I opened the image and use the flag DicomGetImageFlags.None. After that called GetPixelData for specific point. How to get pixelintensity in this case to use the formula HU = PixelIntensity * RescaleSlope + RescaleIntercept ?

#4 Posted : Tuesday, April 23, 2013 8:38:36 AM(UTC)

Groups: Registered, Tech Support
Posts: 179

The Hounsfield Units calculated according to the equation should give you the correct value. If you tried them and didn't give you correct values, please send us the following:
1. Sample image.
2. Explain which pixel you tested.
3. What value you've got.
4. What value you expected.
Mohamed Abedallah
Developer Support Engineer

#5 Posted : Tuesday, April 23, 2013 8:26:16 PM(UTC)

Groups: Registered
Posts: 43

My qustion is I loaded the dicom file usign the flag DicomGetImageFlags as none.
Then I called the GetPixelData for some x,y co-ordinate. How to get pixelintensity from byte array returned using GetPixelData? so that I can use the formula dHU = nPixelIntensity * m_dRescaleSlope + m_dRescaleIntercept

#6 Posted : Wednesday, April 24, 2013 6:22:43 AM(UTC)

Groups: Registered, Tech Support
Posts: 179

If you're asking where to get the RescaleSlope and RescaleIntercept values, they are usually stored in the DICOM dataset itself. If you can't find them, send us the dataset in a ZIP or RAR file and I will check it for you.
Mohamed Abedallah
Developer Support Engineer

#7 Posted : Wednesday, April 24, 2013 8:11:58 PM(UTC)

Groups: Registered
Posts: 43

No.
My question is from where to get Pixelintensity ?
and How to get Pixelintensity ?
If flag DicomGetImageFlags.None is set.

#8 Posted : Thursday, April 25, 2013 5:56:41 AM(UTC)

Groups: Registered, Tech Support
Posts: 179

If the image is grayscale, the intensity is the pixel's value taken from its bytes.
For more details, please tell me which programming language you're using, which version of LEADTOOLS, and which programming interface (C DLLs, RasterCOM, C++ Classes, Main OCX, VCL, .NET assemblies, etc.)
Mohamed Abedallah
Developer Support Engineer

#9 Posted : Thursday, April 25, 2013 9:55:34 PM(UTC)

Groups: Registered
Posts: 43

We are using LT 14.5(patch 77) and VB 6.0 for windows application and LT 14.5 (patch 77) and javascript for web based applications.
We are using RasterCOM.

#10 Posted : Sunday, April 28, 2013 3:07:54 AM(UTC)

Groups: Registered, Tech Support
Posts: 179

If you have a LEADRaster object, such as the Raster member of a LEADRasterView control, you can get the intensity of a 16-bit pixel like this:
Dim hiByte As Long, loByte As Long
loByte = vrnt.ShortItemValue(0)
hiByte = vrnt.ShortItemValue(1)

Dim intensityValue As Long
intensityValue = hiByte * 256 + loByte
MsgBox intensityValue
Mohamed Abedallah
Developer Support Engineer