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 vir 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.
Public Function CalculatePixelHU(ByVal x As Integer, ByVal yAs Integer) As Short 'get the slope and intercept Dim m As Short = CType(Viewer.CurrentImage.Attributes.Item(&H28, &H1053).Value, Int32) Dim b As Short = CType(Viewer.CurrentImage.Attributes.Item(&H28, &H1052).Value, Int32) 'Move pixels into an array and select the pixel under the mouse pixels = Viewer.CurrentImage.Pixels 'where pixels is a Private Object Dim xo = Viewer.ImageXPosition(x, y) 'where x & y are the mouse coordinate on the viewer Dim yo = Viewer.ImageYPosition(x, y) 'calculate HU Return pixels(xo, yo, 1) * m + b End Function
Alternately the better solution is to allow DicomObjects to handle the calculation for you. The ROI mean function will return a HU value without having to add in the slope and intercept.
Here we are creating a rectangular label, 1 pixel big
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