Hounsfield Units
Hounsfield Units (HU) are used in CT images it is a measure of radio-density, calibrated to distilled water and free air.
HUs can be calculated from the pixel data with a Dicom Image via two methods.
The first (and harder) method involves using the Slope and Intercept value from the Dicom image and applying it to a target pixel.
HU = m * P + b
where: m is the Dicom attribute (0028,1053) “Rescale slope” b is the Dicom attribute (0028,1052) “Rescale intercept” P is the value of that particular pixel in the pixels array.
However, it can be done in a much easier and better by using the ROIMean function of DicomLabel as demonstrated in the code below.
DicomObjects.NET
public DicomLabel CreateRoiLabel() // this is run once
{
// create a label
return new DicomLabel()
{
LabelType = LabelType.Rectangle,
Width = 1, // one pixel big
Height = 1,
ScaleMode = ScaleMode.Image, // must be image tied for ROI mean to work
Visible = false,
Left = 1,
Top = 1,
};
}
public double CalculatePixelHU(int x, int y)
{
Viewer.CurrentImage.Labels.Clear();
PointF p= Viewer.ImagePosition(new Point(x, y)); //convert viewer coordinate to image coordinate
DicomLabel l = CreateRoiLabel();
Viewer.CurrentImage.Labels.Add(l);
return l.ROIMean(Viewer.CurrentImage, true);
}
DicomObjects.COM
Public Function CreateRoiLabel() ' this is run once
If RoiLabel Is Nothing Then ' where RoiLabel is a DicomLabel (global)
RoiLabel = New DicomObjects.DicomLabel ' create a label
RoiLabel.LabelType = DicomObjects.doLabelType.doLabelRectangle
RoiLabel.Width = 1 ' one pixel big
RoiLabel.Height = 1
RoiLabel.ImageTied = True ' must be image tied for ROI mean to work
RoiLabel.Visible = False
RoiLabel.Left = 1
RoiLabel.Top = 1
currentImage.Labels.Add(RoiLabel) ' add the label to the current image
End If
End Function
' We then place the label at the mouse location and then get DicomObjects to calculate the Hounsfield Units
Public Function CalculatePixelHU(ByVal x As Integer, ByVal y As Integer) As Short
RoiLabel.Left = Viewer.ImageXPosition(x, y) 'convert viewer coordinate to image coordinate
RoiLabel.Top = Viewer.ImageYPosition(x, y) 'and move RoiLabel to mouse
Return (currentImage.Labels(currentImage.Labels.IndexOf(RoiLabel)).ROIMean())
End Function