ImageEn, unit iexBitmaps

TIOParams.DICOM_PixelToValue

TIOParams.DICOM_PixelToValue

Declaration

function DICOM_PixelToValue(PixelValue: Double; PixelFormat: TIEPixelFormat = ie16g): Double;

Description

Returns the original value of a pixel of a grayscale DICOM image after applying the Modality LUT (DICOM_RescaleSlope and DICOM_RescaleIntercept), e.g. the Hounsfield units of a CT image.
This takes into account the adjustments that are made to pixel values when loading, so it works whether the image was loaded using iedrAdjust or iedrSetBlackWhite (see DICOM_Range).
PixelFormat is the pixel format of the bitmap (ie8g or ie16g). If you change the pixel format after loading (e.g. from ie16g to ie8g), pass the new pixel format.

Note:
◼With iedrAdjust, pixel values outside of the window (DICOM_WindowCenter and DICOM_WindowWidth) are clipped when loading, so the result is only accurate within the window. Use iedrSetBlackWhite to retain all values
◼Set NativePixelFormat to True before loading, so 16 bit images are loaded as ie16g
◼The result is not valid if the pixel values have been modified after loading (e.g. by StretchValues or image processing)
◼If the original value cannot be determined (e.g. color images) the result is: PixelValue * DICOM_RescaleSlope + DICOM_RescaleIntercept

Example

// Show the Hounsfield units of the pixel under the cursor
procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
  bx, by: Integer;
  hu: Double;
begin
  bx := ImageEnView1.XScr2Bmp( X );
  by := ImageEnView1.YScr2Bmp( Y );
  if ( ImageEnView1.IEBitmap.PixelFormat = ie16g ) and
     ( bx >= 0 ) and ( bx < ImageEnView1.IEBitmap.Width ) and ( by >= 0 ) and ( by < ImageEnView1.IEBitmap.Height ) then
  begin
    hu := ImageEnView1.IO.Params.DICOM_PixelToValue( ImageEnView1.IEBitmap.Pixels_ie16g[ bx, by ] );
    lblValue.Caption := Format( '%.0f HU', [ hu ]);
  end;
end;

See Also

◼DICOM_RescaleSlope
◼DICOM_RescaleIntercept
◼DICOM_Range