<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
h1
        {mso-style-priority:9;
        mso-style-link:"\00DCberschrift 1 Zchn";
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:24.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Sprechblasentext Zchn";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-US;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.SprechblasentextZchn
        {mso-style-name:"Sprechblasentext Zchn";
        mso-style-priority:99;
        mso-style-link:Sprechblasentext;
        font-family:"Tahoma","sans-serif";}
span.berschrift1Zchn
        {mso-style-name:"\00DCberschrift 1 Zchn";
        mso-style-priority:9;
        mso-style-link:"\00DCberschrift 1";
        font-family:"Times New Roman","serif";
        mso-fareast-language:DE-AT;
        font-weight:bold;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.bold
        {mso-style-name:bold;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE-AT link=blue vlink=purple><div class=WordSection1><h1 style='margin:0cm;margin-bottom:.0001pt;background:white'><span style='font-size:16.5pt;font-family:"Arial","sans-serif";color:#222426'><a href="http://stackoverflow.com/questions/35083162/vtk-dicom-reslice-axial-coronal-and-sagittal-view"><span lang=EN-US style='font-size:18.0pt;color:#222426;border:none windowtext 1.0pt;padding:0cm;font-weight:normal;text-decoration:none'>vtk dicom reslice axial, coronal and sagittal view</span></a></span><span lang=EN-US style='font-size:16.5pt;font-family:"Arial","sans-serif";color:#222426'><o:p></o:p></span></h1><h1 style='margin:0cm;margin-bottom:.0001pt;background:white'><span lang=EN-US style='font-size:16.5pt;font-family:"Arial","sans-serif";color:#222426'><o:p> </o:p></span></h1><h1 style='margin:0cm;margin-bottom:.0001pt;background:white'><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>I have a problem with calculating the correct<span class=apple-converted-space> </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axial</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>, coronal and sagittal images from a given DICOM series. I use the<span class=apple-converted-space> </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtk</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>-example in:<span class=apple-converted-space> </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>VTK</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>\Examples\ImageProcessing\Cxx\ImageSlicing.cxx :<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>     </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkDICOMReader</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> dicomReader =    <span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkDICOMReader</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>dicomReader->SetFileNames(sortedFileNames);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->SetDataScalarTypeToUnsignedChar();<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->AutoRescaleOn();<span class=apple-converted-space> </span></span><br><br><span style='background:white'>dicomReader->SetGlobalWarningDisplay(1);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->Update();<span class=apple-converted-space> </span></span><br><br><span style='background:white'>int* dicomExtent = new int[6];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetDataExtent(dicomExtent);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* dicomOrigin = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetDataOrigin(dicomOrigin);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* dicomSpacing = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetDataSpacing(dicomSpacing);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double dicomCenter[3];  <span class=apple-converted-space> </span></span><br><span style='background:white'>dicomCenter[0] = dicomOrigin[0] + dicomSpacing[0] * 0.5 * (dicomExtent[0] + dicomExtent[1]);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomCenter[1] = dicomOrigin[1] + dicomSpacing[1] * 0.5 * (dicomExtent[2] + dicomExtent[3]);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomCenter[2] = dicomOrigin[2] + dicomSpacing[2] * 0.5 * (dicomExtent[4] + dicomExtent[5]);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>// Matrices for<span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axial</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>, coronal, sagittal, oblique view orientations<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>static double<span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axialElements</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>[16] = {<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>    1, 0, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 1, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 1, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>static double coronalElements[16] = {<span class=apple-converted-space> </span></span><br><span style='background:white'>    1, 0, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 1, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, -1, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>    static double sagittalElements[16] = {<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, -1, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    1, 0, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, -1, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>//static double obliqueElements[16] = {<span class=apple-converted-space> </span></span><br><span style='background:white'>//         1, 0, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>//         0, 0.866025, -0.5, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>//         0, 0.5, 0.866025, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>//         0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>// Set the slice orientation<span class=apple-converted-space> </span></span><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkMatrix4x4</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> </span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span class=apple-converted-space><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>=<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>   <span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkMatrix4x4</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->DeepCopy(</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axialElements</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>// Set the point through which to slice<span class=apple-converted-space> </span></span><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetElement(0, 3, dicomCenter[0]);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetElement(1, 3, dicomCenter[1]);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetElement(2, 3, dicomCenter[2]);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>// Extract a slice in the desired orientation<span class=apple-converted-space> </span></span><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkImageReslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> </span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span class=apple-converted-space><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>=<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>   <span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkImageReslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetInputConnection(dicomReader->GetOutputPort());<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetOutputDimensionality(2);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetResliceAxes(</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetInterpolationModeToLinear();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->Update();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><br><span style='background:white'>The problem is, that the matrices for the<span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axial</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>, coronal and sagittal orientation only work if the direction cosines form an identity matrix. But I have lots of DICOM series with arbitrary direction cosines, like: 0.758921/ 0.498738/ 0.418688/ -0.00570692/ 0.648034/ -0.76159 So I thought that I should use the direction cosines in the<span class=apple-converted-space> </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axial</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>, coronal and sagittal matrix; this is my code:<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>   <span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkDICOMReader</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> dicomReader =<span class=apple-converted-space> </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkDICOMReader</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>dicomReader->SetFileNames(sortedFileNames);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->SetDataScalarTypeToUnsignedChar();<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->AutoRescaleOn();<span class=apple-converted-space> </span></span><br><br><span style='background:white'>dicomReader->SetGlobalWarningDisplay(1);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->Update();<span class=apple-converted-space> </span></span><br><br><span style='background:white'>int* dicomExtent = new int[6];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetDataExtent(dicomExtent);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* dicomOrigin = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetDataOrigin(dicomOrigin);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* dicomSpacing = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetDataSpacing(dicomSpacing);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double dicomCenter[3];  <span class=apple-converted-space> </span></span><br><span style='background:white'>dicomCenter[0] = dicomOrigin[0] + dicomSpacing[0] * 0.5 * (dicomExtent[0] + dicomExtent[1]);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomCenter[1] = dicomOrigin[1] + dicomSpacing[1] * 0.5 * (dicomExtent[2] + dicomExtent[3]);<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomCenter[2] = dicomOrigin[2] + dicomSpacing[2] * 0.5 * (dicomExtent[4] + dicomExtent[5]);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* directionCosine = new double[6];<span class=apple-converted-space> </span></span><br><span style='background:white'>dicomReader->GetMedicalImageProperties()->GetDirectionCosine(directionCosine);<span class=apple-converted-space> </span></span><br><span style='background:white'>double* xAxis = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>xAxis[0] = directionCosine[0];<span class=apple-converted-space> </span></span><br><span style='background:white'>xAxis[1] = directionCosine[1];<span class=apple-converted-space> </span></span><br><span style='background:white'>xAxis[2] = directionCosine[2];<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* yAxis = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>yAxis[0] = directionCosine[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>yAxis[1] = directionCosine[4];<span class=apple-converted-space> </span></span><br><span style='background:white'>yAxis[2] = directionCosine[5];<span class=apple-converted-space> </span></span><br><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkMath</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> math =<span class=apple-converted-space> </span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkMath</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>double* zAxis = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>math->Cross(xAxis, yAxis, zAxis);<span class=apple-converted-space> </span></span><br><br><span style='background:white'>// Matrices for<span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axial</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>, coronal, sagittal, oblique view orientations<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>//xy<span class=apple-converted-space> </span></span><br><span style='background:white'>static double<span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axialElements</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>[16] = {<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>    xAxis[0], yAxis[0], zAxis[0], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    xAxis[1], yAxis[1], zAxis[1], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    xAxis[2], yAxis[2], zAxis[2], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><br><span style='background:white'>double* yCross = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>math->Cross(xAxis, zAxis, yCross);<span class=apple-converted-space> </span></span><br><span style='background:white'>//xz<span class=apple-converted-space> </span></span><br><span style='background:white'>static double coronalElements[16] = {<span class=apple-converted-space> </span></span><br><span style='background:white'>    xAxis[0], zAxis[0], yCross[0], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    xAxis[1], zAxis[1], yCross[1], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    xAxis[2], zAxis[2], yCross[2], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>double* xCross = new double[3];<span class=apple-converted-space> </span></span><br><span style='background:white'>math->Cross(yAxis, zAxis, xCross);<span class=apple-converted-space> </span></span><br><span style='background:white'>//yz<span class=apple-converted-space> </span></span><br><span style='background:white'>static double sagittalElements[16] = {<span class=apple-converted-space> </span></span><br><span style='background:white'>    yAxis[0], zAxis[0], xCross[0], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    yAxis[1], zAxis[1], xCross[1], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    yAxis[2], zAxis[2], xCross[2], 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>    0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>//static double obliqueElements[16] = {<span class=apple-converted-space> </span></span><br><span style='background:white'>//         1, 0, 0, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>//         0, 0.866025, -0.5, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>//         0, 0.5, 0.866025, 0,<span class=apple-converted-space> </span></span><br><span style='background:white'>//         0, 0, 0, 1 };<span class=apple-converted-space> </span></span><br><br><span style='background:white'>// Set the slice orientation<span class=apple-converted-space> </span></span><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkMatrix4x4</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> </span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span class=apple-converted-space><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>=<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>   <span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkMatrix4x4</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->DeepCopy(</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>axialElements</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>// Set the point through which to slice<span class=apple-converted-space> </span></span><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetElement(0, 3, dicomCenter[0]);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetElement(1, 3, dicomCenter[1]);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetElement(2, 3, dicomCenter[2]);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>// Extract a slice in the desired orientation<span class=apple-converted-space> </span></span><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkImageReslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>> </span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span class=apple-converted-space><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>=<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><span style='background:white'>   <span class=apple-converted-space> </span></span></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkSmartPointer</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'><</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>vtkImageReslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>>::New();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetInputConnection(dicomReader->GetOutputPort());<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetOutputDimensionality(2);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetResliceAxes(</span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>resliceAxes</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>);<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->SetInterpolationModeToLinear();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br></span><span class=bold><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:#FFFF99;font-weight:normal'>reslice</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>->Update();<span class=apple-converted-space> </span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'><br><br><span style='background:white'>But it does not work. I also tried to use the inverse of the direction cosines, but the result is not correct. Can someone help me with my problem? Thank you in advance!<span class=apple-converted-space> </span></span><br><br></span><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black;background:white'>Kind regards, Pia</span><span lang=EN-US style='font-size:16.5pt;font-family:"Arial","sans-serif";color:#222426'><o:p></o:p></span></h1><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=129 style='border-collapse:collapse'><tr><td width=129 valign=bottom style='width:97.0pt;border:solid white 1.0pt;padding:0cm 5.4pt 0cm 5.4pt'></td></tr></table><p class=MsoNormal><span style='mso-fareast-language:DE-AT'><o:p> </o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>