From fa5ba901a8371262c5d8b0173689dbc10f400923 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Tue, 13 Feb 2018 10:04:41 +0100 Subject: [PATCH 1/2] Rearrange slice-extraction loops, so that they better corresponds with the order on screen. --- TestViewer/MainWindow.xaml.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/TestViewer/MainWindow.xaml.cs b/TestViewer/MainWindow.xaml.cs index 016e5dc..7cf626d 100644 --- a/TestViewer/MainWindow.xaml.cs +++ b/TestViewer/MainWindow.xaml.cs @@ -84,17 +84,18 @@ private void DrawImages (uint frame) uint[] color_map = m_source.GetColorMap(); { - // extract center-X slize - WriteableBitmap bitmap = new WriteableBitmap(image.dims[1], image.dims[2], 96.0, 96.0, PixelFormats.Rgb24, null); + // extract center-Z slize (top-left) + WriteableBitmap bitmap = new WriteableBitmap(image.dims[0], image.dims[1], 96.0, 96.0, PixelFormats.Rgb24, null); bitmap.Lock(); - unsafe { - int x = image.dims[0] / 2; + unsafe + { + int z = image.dims[2] / 2; for (int y = 0; y < bitmap.Height; ++y) { - for (int z = 0; z < bitmap.Width; ++z) + for (int x = 0; x < bitmap.Width; ++x) { byte val = image.data[x + y * image.stride0 + z * image.stride1]; - byte* pixel = (byte*)bitmap.BackBuffer + z * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride; + byte* pixel = (byte*)bitmap.BackBuffer + x * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride; SetRGBVal(pixel, color_map[val]); } } @@ -102,10 +103,10 @@ private void DrawImages (uint frame) bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight)); bitmap.Unlock(); - ImageYZ.Source = bitmap; + ImageXY.Source = bitmap; } { - // extract center-Y slize + // extract center-Y slize (top-right) WriteableBitmap bitmap = new WriteableBitmap(image.dims[0], image.dims[2], 96.0, 96.0, PixelFormats.Rgb24, null); bitmap.Lock(); unsafe @@ -127,18 +128,17 @@ private void DrawImages (uint frame) ImageXZ.Source = bitmap; } { - // extract center-Z slize - WriteableBitmap bitmap = new WriteableBitmap(image.dims[0], image.dims[1], 96.0, 96.0, PixelFormats.Rgb24, null); + // extract center-X slize (bottom-left) + WriteableBitmap bitmap = new WriteableBitmap(image.dims[1], image.dims[2], 96.0, 96.0, PixelFormats.Rgb24, null); bitmap.Lock(); - unsafe - { - int z = image.dims[2] / 2; + unsafe { + int x = image.dims[0] / 2; for (int y = 0; y < bitmap.Height; ++y) { - for (int x = 0; x < bitmap.Width; ++x) + for (int z = 0; z < bitmap.Width; ++z) { byte val = image.data[x + y * image.stride0 + z * image.stride1]; - byte* pixel = (byte*)bitmap.BackBuffer + x * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride; + byte* pixel = (byte*)bitmap.BackBuffer + z * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride; SetRGBVal(pixel, color_map[val]); } } @@ -146,7 +146,7 @@ private void DrawImages (uint frame) bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight)); bitmap.Unlock(); - ImageXY.Source = bitmap; + ImageYZ.Source = bitmap; } } From 095b904d872e2600229b31909f1646a7d6176db0 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Tue, 13 Feb 2018 10:09:35 +0100 Subject: [PATCH 2/2] Flip YZ-plane, so that the Y-axis is horizontal and better corresponds with the probe being on top. --- TestViewer/MainWindow.xaml.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestViewer/MainWindow.xaml.cs b/TestViewer/MainWindow.xaml.cs index 7cf626d..f4d1689 100644 --- a/TestViewer/MainWindow.xaml.cs +++ b/TestViewer/MainWindow.xaml.cs @@ -129,16 +129,16 @@ private void DrawImages (uint frame) } { // extract center-X slize (bottom-left) - WriteableBitmap bitmap = new WriteableBitmap(image.dims[1], image.dims[2], 96.0, 96.0, PixelFormats.Rgb24, null); + WriteableBitmap bitmap = new WriteableBitmap(image.dims[2], image.dims[1], 96.0, 96.0, PixelFormats.Rgb24, null); bitmap.Lock(); unsafe { int x = image.dims[0] / 2; - for (int y = 0; y < bitmap.Height; ++y) + for (int z = 0; z < bitmap.Height; ++z) { - for (int z = 0; z < bitmap.Width; ++z) + for (int y = 0; y < bitmap.Width; ++y) { byte val = image.data[x + y * image.stride0 + z * image.stride1]; - byte* pixel = (byte*)bitmap.BackBuffer + z * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride; + byte* pixel = (byte*)bitmap.BackBuffer + y * (bitmap.Format.BitsPerPixel / 8) + z * bitmap.BackBufferStride; SetRGBVal(pixel, color_map[val]); } }