DICOM ファイルから生のピクセル データを 180 度回転 (または反転) しようとしています。ただし、ピクセル データをファイル (この場合は DICOM ファイル) に書き戻して表示すると、画像が正しく反転されました。画像の最終出力が正しくありません。
以下は、180/mirror を反転しようとしている画像のサンプルです。
フリッピングを実行するために使用しているコードは次のとおりです。
string file = @"adicomfile.dcm";
DicomFile df = new DicomFile();
df.Load(file);
// Get the amount of bits per pixel from the DICOM header.
int bitsPerPixel = df.DataSet[DicomTags.BitsAllocated].GetInt32(0, 0);
// Get the raw pixel data from the DICOM file.
byte[] bytes = df.DataSet[DicomTags.PixelData].Values as byte[];
// Get the width and height of the image.
int width = df.DataSet[DicomTags.Columns].GetInt32(0, 0);
int height = df.DataSet[DicomTags.Rows].GetInt32(0, 0);
byte[] original = bytes;
byte[] mirroredPixels = new byte[width * height * (bitsPerPixel / 8)];
width *= (bitsPerPixel / 8);
// The mirroring / image flipping.
for (int i = 0; i < original.Length; i++)
{
int mod = i % width;
int x = ((width - mod - 1) + i) - mod;
mirroredPixels[i] = original[x];
}
df.DataSet[DicomTags.PixelData].Values = mirroredPixels;
df.Save(@"flippedicom.dcm", DicomWriteOptions.Default);
そして、これが私の出力です(間違っています)。白と歪みは、望ましい出力ではありません。
私は ClearCanvas DICOM ライブラリを使用していますが、ファイル自体に含まれる生のピクセル データを操作しようとしているだけなので、これは問題ではありません。
目的の出力は、元のように見えることが望ましいですが、180 度反転/ミラー化されています。
いくつかの支援をいただければ幸いです。SOを検索するために最善を尽くしましたが、役に立ちませんでした。