# the picture of coronal plane's left and right is reversion in vtk8.2.0 dicom mpr

**URL:** https://discourse.vtk.org/t/the-picture-of-coronal-planes-left-and-right-is-reversion-in-vtk8-2-0-dicom-mpr/1754
**Category:** Support
**Created:** [September 12, 2019, 9:58am UTC](https://discourse.vtk.org/t/the-picture-of-coronal-planes-left-and-right-is-reversion-in-vtk8-2-0-dicom-mpr/1754 "2019-09-12T09:58:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chenzongxi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/chenzongxi/32/1368_2.png) [@chenzongxi](https://discourse.vtk.org/u/chenzongxi)
#### Post date: [September 12, 2019, 9:58am UTC](https://discourse.vtk.org/t/the-picture-of-coronal-planes-left-and-right-is-reversion-in-vtk8-2-0-dicom-mpr/1754/1 "2019-09-12T09:58:20Z")

</div>

Hi, I use vs2017 to run the demo of dicom mpr(multi-planner reformation) with vtk8.2.0.  
The picture of transverse surface and sagittal plane is correct.  
But the picture of coronal plane is reverse of left and right.  
I have set the camera position and viewup, but it does not work.  
Even the demo of VTK-8.2.0\Examples\GUI\Qt\FourPaneViewer is the same problem.  
The radiant can show the right picture of coronal plane with the same dicom series files.

I find that move the cross line to 180 degrees ,the coronal plane become to be right. But i donot know how to control the line.  
I donot know how to fix it.  
Thank you.

the configure of camera is:  
double camPos[3][3] = { { 0, 0, 1 }, { 0, 1, 0 }, { 1, 0, 0 } };  
double viewUp[3][3] = { { 0, 1, 0 }, { 0, 0, -1 }, { 0, 0, -1 } };

the result of vtk is:

 ![vtk](https://discourse.vtk.org/uploads/default/original/1X/5cfce8ad2b0dc7cfb82d2e1b8765fb15cbc24e35.jpeg)  
the result of radiant is:  
 ![radiant](https://discourse.vtk.org/uploads/default/original/1X/3de5b50fa266c5978f86f75c959e4e97cef45aed.png)

---

<div class="post-metadata">

### Author: ![chenzongxi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/chenzongxi/32/1368_2.png) [@chenzongxi](https://discourse.vtk.org/u/chenzongxi)
#### Post date: [September 12, 2019, 10:08am UTC](https://discourse.vtk.org/t/the-picture-of-coronal-planes-left-and-right-is-reversion-in-vtk8-2-0-dicom-mpr/1754/2 "2019-09-12T10:08:39Z")

</div>

I mainly use this classes:  
vtkResliceCursor,  
vtkResliceCursorLineRepresentation，  
vtkResliceCursorWidget

the code is:  
#include “vtkSmartPointer.h”  
#include “vtkActor.h”  
#include “vtkCamera.h”  
#include “vtkCellPicker.h”  
#include “vtkCommand.h”  
#include “vtkImageActor.h”  
#include “vtkImageReslice.h”  
#include “vtkInteractorStyleImage.h”  
#include “vtkImageMapToColors.h”  
#include “vtkImagePlaneWidget.h”  
#include “vtkImageReader.h”  
#include “vtkInteractorEventRecorder.h”  
#include “vtkLookupTable.h”  
#include “vtkOutlineFilter.h”  
#include “vtkDICOMImageReader.h”  
#include “vtkPolyDataMapper.h”  
#include “vtkProperty.h”  
#include “vtkRenderWindow.h”  
#include “vtkRenderWindowInteractor.h”  
#include “vtkRenderer.h”  
#include “vtkImageData.h”  
#include “vtkPointData.h”  
#include “vtkPlaneSource.h”  
#include “vtkPlane.h”  
#include “vtkResliceCursorActor.h”  
#include “vtkResliceCursorPolyDataAlgorithm.h”  
#include “vtkResliceCursor.h”  
#include “vtkResliceCursorWidget.h”  
#include “vtkResliceCursorLineRepresentation.h”  
#include “vtkBiDimensionalWidget.h”  
#include"vtkAutoInit.h"  
#include"vtkAxesActor.h"  
#include"vtkTransform.h"  
#include"vtkTextActor.h"  
#include"vtkProperty2D.h"  
#include “vtkAutoInit.h”  
#include “vtkConeSource.h”  
#include \<vtkImageViewer2.h\>  
#include \<vtkActor2DCollection.h\>  
#include \<vtkActor2D.h\>

VTK\_MODULE\_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2  
//VTK\_MODULE\_INIT(vtkRenderingOpenGL);  
VTK\_MODULE\_INIT(vtkInteractionStyle);  
VTK\_MODULE\_INIT(vtkRenderingFreeType);  
//VTK\_MODULE\_INIT(vtkRenderingVolumeOpenGL);

void MPR()  
{  
vtkSmartPointer reader = vtkSmartPointer::New();  
//文件所在的目录，全路径，不能时父级目录  
reader-\>SetDirectoryName(“E:\11”);  
reader-\>Update();

```
vtkSmartPointer<vtkRenderer> ren[4];
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
//renWin->SetMultiSamples(0);

for (int i = 0; i < 4; i++)
{
	ren[i] = vtkSmartPointer<vtkRenderer>::New();
	renWin->AddRenderer(ren[i]);
}

vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
vtkSmartPointer< vtkInteractorStyleImage > style = vtkSmartPointer< vtkInteractorStyleImage >::New();
iren->SetInteractorStyle(style);

vtkSmartPointer< vtkResliceCursor > resliceCursor = vtkSmartPointer< vtkResliceCursor >::New();

resliceCursor->SetImage(reader->GetOutput());
resliceCursor->SetCenter(reader->GetOutput()->GetCenter());
//resliceCursor->SetThickMode(0);
//resliceCursor->SetThickness(10, 10, 10);

vtkSmartPointer< vtkResliceCursorWidget > resliceCursorWidget[3];
vtkSmartPointer< vtkResliceCursorLineRepresentation > resliceCursorRep[3];

//vkt世界坐标是从左往右x轴，从下往上y轴，从内到外z轴，dicom坐标是沿着z轴反向，脚朝外头朝内
//camPos和viewUp依次是横截面，冠状面，矢状面
double camPos[3][3] = { { 0, 0, 1 }, { 0, 1, 0 }, { 1, 0, 0 } };
double viewUp[3][3] = { { 0, 1, 0 }, { 0, 0, -1 }, { 0, 0, -1 } };

for (int i = 0; i < 3; i++)
{
	
	resliceCursorRep[i] = vtkSmartPointer< vtkResliceCursorLineRepresentation >::New();

	resliceCursorRep[i]->GetResliceCursorActor()->GetCursorAlgorithm()->SetResliceCursor(resliceCursor);

	
	//平面法向量，横截面法向量是z轴（2），冠状面法向量是y轴（1），矢状面法向量是x轴（0）
	//和camPos和viewUp要对应，render1是横截面，render2是冠状面，render3是矢状面。
	resliceCursorRep[i]->GetResliceCursorActor()->GetCursorAlgorithm()->SetReslicePlaneNormal(2 - i);
	double range[2];
	reader->GetOutput()->GetScalarRange(range);
	resliceCursorRep[i]->SetWindowLevel(range[1] - range[0], (range[0] + range[1]) / 2.0);
	//ww,wl共享，调一个面，其他面变化
	resliceCursorRep[i]->SetLookupTable(resliceCursorRep[0]->GetLookupTable());
	const double minVal = reader->GetOutput()->GetScalarRange()[0];
	if (vtkImageReslice *reslice = vtkImageReslice::SafeDownCast(resliceCursorRep[i]->GetReslice()))
	{
		reslice->SetBackgroundColor(minVal, minVal, minVal, minVal);
	}

	resliceCursorWidget[i] = vtkSmartPointer< vtkResliceCursorWidget >::New();
	resliceCursorWidget[i]->SetInteractor(iren);
	resliceCursorWidget[i]->SetRepresentation(resliceCursorRep[i]);
	resliceCursorWidget[i]->SetDefaultRenderer(ren[i]);
	resliceCursorWidget[i]->On();
	resliceCursorRep[i]->GetResliceCursorActor()->GetCenterlineProperty(0)->SetColor(1, 0, 0);
	resliceCursorRep[i]->GetResliceCursorActor()->GetCenterlineProperty(1)->SetColor(1, 0, 0);

	ren[i]->GetActiveCamera()->SetFocalPoint(0, 0, 0);
	ren[i]->GetActiveCamera()->SetPosition(camPos[i][0], camPos[i][1], camPos[i][2]);
	ren[i]->GetActiveCamera()->SetViewUp(viewUp[i][0], viewUp[i][1], viewUp[i][2]);
	ren[i]->GetActiveCamera()->ParallelProjectionOn();
	ren[i]->ResetCamera();
}

vtkActor *actor = ren[1]->GetActors()->GetNextActor();
ren[0]->SetBackground(0, 0, 0);
ren[1]->SetBackground(0, 0, 0);
ren[2]->SetBackground(0, 0, 0);
//ren[3]->AddActor(outlineActor);
//ren[3]->SetBackground(0, 0, 0);

ren[0]->SetViewport(0, 0.5, 0.5, 1);
ren[1]->SetViewport(0.5, 0.5, 1, 1);
ren[2]->SetViewport(0, 0, 0.5, 0.5);
ren[3]->SetViewport(0.5, 0, 1, 0.5);

renWin->SetSize(1000, 1000);
renWin->Render();

```

#ifdef three  
ren[3]-\>GetActiveCamera()-\>Elevation(110);  
ren[3]-\>GetActiveCamera()-\>SetViewUp(0, 0, -1);  
ren[3]-\>GetActiveCamera()-\>Azimuth(45);  
ren[3]-\>GetActiveCamera()-\>Dolly(1.15);  
ren[3]-\>ResetCameraClippingRange();  
#endif

```
iren->Initialize();
reader->Delete();
iren->Start();

```

}

int main()  
{  
//dicom();  
MPR();  
return EXIT\_SUCCESS;

---

<div class="post-metadata">

### Author: ![chenzongxi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/chenzongxi/32/1368_2.png) [@chenzongxi](https://discourse.vtk.org/u/chenzongxi)
#### Post date: [September 12, 2019, 1:38pm UTC](https://discourse.vtk.org/t/the-picture-of-coronal-planes-left-and-right-is-reversion-in-vtk8-2-0-dicom-mpr/1754/3 "2019-09-12T13:38:33Z")

</div>

Is this a bug?
