1

C# で DICOM-Image Viewer を実装しています。私は (許可されていないため) 画像処理を行うフレームワークやライブラリを使用しません。

ウィンドウ処理を計算するには、どのアルゴリズムを使用しますか? (ウィンドウの中心とウィンドウの幅)

次の作業があります。

  • ピクセル データは byte[] として格納されます。
  • ピクセルはハウンズフィールド単位で保存されます (最初のコードを参照)

私は次のことを試しました:

再スケールの計算: (編集済み)

var intArray = new int[PixelData.Length];
for (int i = 0; i < this.PixelData.Length; i++)
{
  intArray[i] = rescaleSlope*this.PixelData[i] + rescaleIntercept;
}

ウィンドウ処理の計算

var lowestVisibleValue = (windowCenter - 0.5 - ((windowWidth - 1) / 2));
var highestVisibleValue = (windowCenter - 0.5 + ((windowWidth - 1) / 2));

for (int i = 0; i < this.PixelData.Length; i++)
{
  if (intArray[i] <=  lowestVisibleValue)
  {
    PixelData[i] = 0;
  }
  else if (intArray[i] > highestVisibleValue)
  {
    PixelData[i] = 255;
  }
  else
  {
    PixelData[i] =(byte)((PixelData[i] - (windowCenter - 0.5))/((windowWidth -1) + 0.5)*(highestVisibleValue - lowestVisibleValue) + lowestVisibleValue);
  }
}

2 番目のコードはほぼ常に 0 を返すため、画像はほとんど黒です。私が間違っていることはありますか?

編集 21.02.2017

Paolo Brandolis の提案に従ってコードを編集しました。HU を int[] に格納します。
Rescale Intercept はたとえば -1024 で、Rescale Slope は 1 です。Window Center が 40 で Window Width が 350 の場合、すべてが黒になります。
そのため、まだ何かが間違っています。助言がありますか?

4

1 に答える 1