private void InitializeSlices() { Debug.Assert(m_source != null); Cart3dGeom bbox = m_source.GetBoundingBox(); if (Math.Abs(bbox.dir3_y) > Math.Abs(bbox.dir2_y)) { // swap 2nd & 3rd axis, so that the 2nd becomes predominately "Y" SwapVals(ref bbox.dir2_x, ref bbox.dir3_x); SwapVals(ref bbox.dir2_y, ref bbox.dir3_y); SwapVals(ref bbox.dir2_z, ref bbox.dir3_z); } // extend bounding-box axes, so that dir1, dir2 & dir3 have equal length ExtendBoundingBox(ref bbox); // get XY plane (assumes 1st axis is "X" and 2nd is "Y") m_bboxXY = bbox; m_bboxXY.origin_x = m_bboxXY.origin_x + m_bboxXY.dir3_x / 2; m_bboxXY.origin_y = m_bboxXY.origin_y + m_bboxXY.dir3_y / 2; m_bboxXY.origin_z = m_bboxXY.origin_z + m_bboxXY.dir3_z / 2; m_bboxXY.dir3_x = 0; m_bboxXY.dir3_y = 0; m_bboxXY.dir3_z = 0; // get XZ plane (assumes 1st axis is "X" and 3rd is "Z") m_bboxXZ = bbox; m_bboxXZ.origin_x = m_bboxXZ.origin_x + m_bboxXZ.dir2_x / 2; m_bboxXZ.origin_y = m_bboxXZ.origin_y + m_bboxXZ.dir2_y / 2; m_bboxXZ.origin_z = m_bboxXZ.origin_z + m_bboxXZ.dir2_z / 2; m_bboxXZ.dir2_x = m_bboxXZ.dir3_x; m_bboxXZ.dir2_y = m_bboxXZ.dir3_y; m_bboxXZ.dir2_z = m_bboxXZ.dir3_z; m_bboxXZ.dir3_x = 0; m_bboxXZ.dir3_y = 0; m_bboxXZ.dir3_z = 0; // get ZY plane (assumes 2nd axis is "Y" and 3rd is "Z") m_bboxZY = bbox; m_bboxZY.origin_x = bbox.origin_x + bbox.dir1_x / 2; m_bboxZY.origin_y = bbox.origin_y + bbox.dir1_y / 2; m_bboxZY.origin_z = bbox.origin_z + bbox.dir1_z / 2; m_bboxZY.dir1_x = bbox.dir3_x; m_bboxZY.dir1_y = bbox.dir3_y; m_bboxZY.dir1_z = bbox.dir3_z; m_bboxZY.dir2_x = bbox.dir2_x; m_bboxZY.dir2_y = bbox.dir2_y; m_bboxZY.dir2_z = bbox.dir2_z; m_bboxZY.dir3_x = 0; m_bboxZY.dir3_y = 0; m_bboxZY.dir3_z = 0; }
private void DrawImages(uint frame) { Debug.Assert(m_source != null); // retrieve image volume ushort[] max_res = new ushort[] { 128, 128, 128 }; Cart3dGeom bbox = m_source.GetBoundingBox(); if (Math.Abs(bbox.dir3_y) > Math.Abs(bbox.dir2_y)) { // swap 2nd & 3rd axis, so that the 2nd becomes predominately "Y" SwapVals(ref bbox.dir2_x, ref bbox.dir3_x); SwapVals(ref bbox.dir2_y, ref bbox.dir3_y); SwapVals(ref bbox.dir2_z, ref bbox.dir3_z); } // get XY plane (assumes 1st axis is "X" and 2nd is "Y") Cart3dGeom bboxXY = bbox; ushort[] max_resXY = new ushort[] { max_res[0], max_res[1], 1 }; bboxXY.origin_x = bboxXY.origin_x + bboxXY.dir3_x / 2; bboxXY.origin_y = bboxXY.origin_y + bboxXY.dir3_y / 2; bboxXY.origin_z = bboxXY.origin_z + bboxXY.dir3_z / 2; bboxXY.dir3_x = 0; bboxXY.dir3_y = 0; bboxXY.dir3_z = 0; Image3d imageXY = m_source.GetFrame(frame, bboxXY, max_resXY); // get XZ plane (assumes 1st axis is "X" and 3rd is "Z") Cart3dGeom bboxXZ = bbox; ushort[] max_resXZ = new ushort[] { max_res[0], max_res[2], 1 }; bboxXZ.origin_x = bboxXZ.origin_x + bboxXZ.dir2_x / 2; bboxXZ.origin_y = bboxXZ.origin_y + bboxXZ.dir2_y / 2; bboxXZ.origin_z = bboxXZ.origin_z + bboxXZ.dir2_z / 2; bboxXZ.dir2_x = bboxXZ.dir3_x; bboxXZ.dir2_y = bboxXZ.dir3_y; bboxXZ.dir2_z = bboxXZ.dir3_z; bboxXZ.dir3_x = 0; bboxXZ.dir3_y = 0; bboxXZ.dir3_z = 0; Image3d imageXZ = m_source.GetFrame(frame, bboxXZ, max_resXZ); // get YZ plane (assumes 2nd axis is "Y" and 3rd is "Z") Cart3dGeom bboxYZ = bbox; ushort[] max_resYZ = new ushort[] { max_res[1], max_res[2], 1 }; bboxYZ.origin_x = bboxYZ.origin_x + bboxYZ.dir1_x / 2; bboxYZ.origin_y = bboxYZ.origin_y + bboxYZ.dir1_y / 2; bboxYZ.origin_z = bboxYZ.origin_z + bboxYZ.dir1_z / 2; bboxYZ.dir1_x = bboxYZ.dir2_x; bboxYZ.dir1_y = bboxYZ.dir2_y; bboxYZ.dir1_z = bboxYZ.dir2_z; bboxYZ.dir2_x = bboxYZ.dir3_x; bboxYZ.dir2_y = bboxYZ.dir3_y; bboxYZ.dir2_z = bboxYZ.dir3_z; bboxYZ.dir3_x = 0; bboxYZ.dir3_y = 0; bboxYZ.dir3_z = 0; Image3d imageYZ = m_source.GetFrame(frame, bboxYZ, max_resYZ); FrameTime.Text = "Frame time: " + imageXY.time; uint[] color_map = m_source.GetColorMap(); ImageXY.Source = GenerateBitmap(imageXY, color_map); ImageXZ.Source = GenerateBitmap(imageXZ, color_map); ImageYZ.Source = GenerateBitmap(imageYZ, color_map); }
private void DrawImages(uint frame) { Debug.Assert(m_source != null); // retrieve image slices const ushort HORIZONTAL_RES = 256; const ushort VERTICAL_RES = 256; Cart3dGeom bbox = m_source.GetBoundingBox(); if (Math.Abs(bbox.dir3_y) > Math.Abs(bbox.dir2_y)) { // swap 2nd & 3rd axis, so that the 2nd becomes predominately "Y" SwapVals(ref bbox.dir2_x, ref bbox.dir3_x); SwapVals(ref bbox.dir2_y, ref bbox.dir3_y); SwapVals(ref bbox.dir2_z, ref bbox.dir3_z); } // extend bounding-box axes, so that dir1, dir2 & dir3 have equal length ExtendBoundingBox(ref bbox); // get XY plane (assumes 1st axis is "X" and 2nd is "Y") Cart3dGeom bboxXY = bbox; bboxXY.origin_x = bboxXY.origin_x + bboxXY.dir3_x / 2; bboxXY.origin_y = bboxXY.origin_y + bboxXY.dir3_y / 2; bboxXY.origin_z = bboxXY.origin_z + bboxXY.dir3_z / 2; bboxXY.dir3_x = 0; bboxXY.dir3_y = 0; bboxXY.dir3_z = 0; Image3d imageXY = m_source.GetFrame(frame, bboxXY, new ushort[] { HORIZONTAL_RES, VERTICAL_RES, 1 }); // get XZ plane (assumes 1st axis is "X" and 3rd is "Z") Cart3dGeom bboxXZ = bbox; bboxXZ.origin_x = bboxXZ.origin_x + bboxXZ.dir2_x / 2; bboxXZ.origin_y = bboxXZ.origin_y + bboxXZ.dir2_y / 2; bboxXZ.origin_z = bboxXZ.origin_z + bboxXZ.dir2_z / 2; bboxXZ.dir2_x = bboxXZ.dir3_x; bboxXZ.dir2_y = bboxXZ.dir3_y; bboxXZ.dir2_z = bboxXZ.dir3_z; bboxXZ.dir3_x = 0; bboxXZ.dir3_y = 0; bboxXZ.dir3_z = 0; Image3d imageXZ = m_source.GetFrame(frame, bboxXZ, new ushort[] { HORIZONTAL_RES, VERTICAL_RES, 1 }); // get ZY plane (assumes 2nd axis is "Y" and 3rd is "Z") Cart3dGeom bboxZY = bbox; bboxZY.origin_x = bbox.origin_x + bbox.dir1_x / 2; bboxZY.origin_y = bbox.origin_y + bbox.dir1_y / 2; bboxZY.origin_z = bbox.origin_z + bbox.dir1_z / 2; bboxZY.dir1_x = bbox.dir3_x; bboxZY.dir1_y = bbox.dir3_y; bboxZY.dir1_z = bbox.dir3_z; bboxZY.dir2_x = bbox.dir2_x; bboxZY.dir2_y = bbox.dir2_y; bboxZY.dir2_z = bbox.dir2_z; bboxZY.dir3_x = 0; bboxZY.dir3_y = 0; bboxZY.dir3_z = 0; Image3d imageZY = m_source.GetFrame(frame, bboxZY, new ushort[] { HORIZONTAL_RES, VERTICAL_RES, 1 }); FrameTime.Text = "Frame time: " + imageXY.time; uint[] color_map = m_source.GetColorMap(); ImageXY.Source = GenerateBitmap(imageXY, color_map); ImageXZ.Source = GenerateBitmap(imageXZ, color_map); ImageZY.Source = GenerateBitmap(imageZY, color_map); }