Reputation: 419
I am developing a dicom viewer in c#.net . I need a little help on calculating the HU Value of Pixel . I know the formula for calculating the HU is ,
HU = Pixel Value * Rescale Slope + Rescale Intercept
I made some calculations and retrieved from my original dicom pixel value but thats not giving me the right HU value . My question is what is exactly the pixel value . Anyone Help Me On this .
This is my code
public void calculateHU(string x,string y)
{
Int32 intercept, slope,pix;
intercept = -1024;
slope = 1;
int xx, yy;
xx = Convert.ToInt32(x);
yy = Convert.ToInt32(y);
xx = xx +Convert.ToInt32( imagerect.X);
yy = yy + Convert.ToInt32( imagerect.Y);
pix = getpixelvalue(xx,yy);
double hu = pix * slope + intercept;
}
public Int32 getpixelvalue(int x, int y)
{
string c;
c = pix16[imgno][y * bmd.width + x].ToString();
return Convert.ToInt32(c);
}
Upvotes: 0
Views: 2424
Reputation: 15971
If Pixel Representation (0028,0103) is set to 0 (unsigned), the Pixel Data values should be non-negative. According to your example where the intercept and slope are -1024 and 1, respectively, the raw pixel value would have to be -4 to yield HU value -1028.
If you are expecting to obtain resulting HU values as low as -1028, this is most probably managed through a negative enough Rescale Intercept value (and potentially Rescale Slope) value instead.
Rather than hard coding Rescale Intercept and Slope, grab these values from the image, tags (0028,1052) and (0028,1053) respectively, and apply in the HU calculation.
Upvotes: 2