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);
}