<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi all,<br><br>I am doing my own MPR slicer by following the Examples/ImageProcessing/Cxx/ImageSlicing.cxx example. <br>The interface is made with Qt, so I use QVTKwidget as a 3D container.<br><br>The goal is to change the position of the slicing plane (orientation) controlling that orientation with a qslider, showing how the image sliced is changing on the qvtkwidget.<br>It compiles fine, but when I change the values on the matrix to perform that rotation my application crashes.<br><br>The first thing I just want to perform is a simple translation. Then controlling pitch, yaw angles and movements will be straighforward.<br><br>My sourcecode (important parts):<br>....<br>//Load dicom stuff and I export that data with vtkImageImport (vtkImporter contains the 3dImage data)<br>....<br> int dimensiones[6];<br> vtkImporter->GetWholeExtent(dimensiones);<br> qDebug()<<"Xmin:"<<dimensiones[0]<br> <<"Xmax:"<<dimensiones[1]<br> <<"Ymin:"<<dimensiones[2]<br> <<"Ymax:"<<dimensiones[3]<br> <<"Zmin:"<<dimensiones[4]<br> <<"Zmax:"<<dimensiones[5];<br><br> horizontalSlider->setRange(0,dimensiones[5]); //This is my slider with which I want to control the movement of the slicing plane<br><br> double espacing[3];<br> vtkImporter->GetDataSpacing(espacing);<br> double origen[3];<br> vtkImporter->GetDataOrigin(origen);<br> double centro[3]; //Obtenemos el punto centro para ponerselo al plano<br> centro[0]=origen[0] + espacing[0] * 0.5 * (dimensiones[0] + dimensiones[1]);<br> centro[1]=origen[1] + espacing[1] * 0.5 * (dimensiones[2] + dimensiones[3]);<br> centro[2]=origen[2] + espacing[2] * 0.5 * (dimensiones[4] + dimensiones[5]);<br> qDebug()<<"Espacios de voxeles:"<<espacing[0]<<","<<espacing[1]<<","<<espacing[2];<br> qDebug()<<"Coordenadas del origen:"<<origen[0]<<","<<origen[1]<<","<<origen[2];<br> qDebug()<<"Coordenadas del centro:"<<centro[0]<<","<<centro[1]<<","<<centro[2];<br><br> vtkSmartPointer<vtkMatrix4x4> resliceAxes =vtkSmartPointer<vtkMatrix4x4>::New();<br><br>This matrix is which I use to slice the plane and show the 3dImage sliced<br><br> static double matrizRotacion[16] = {<br> 1, 0, 0, centro[0],<br> 0, 1, 0, centro[1],<br> 0, 0, 1, centro[2],<br> 0, 0, 0, 1};<br> resliceAxes->DeepCopy(matrizRotacion);<br> // Extract a slice in the desired orientation<br> reslice = vtkSmartPointer<vtkImageReslice>::New();<br> reslice->SetInputConnection(vtkImporter->GetOutputPort());<br> reslice->SetOutputDimensionality(2);<br> reslice->SetResliceAxes(resliceAxes);<br> reslice->SetInterpolationModeToCubic();<br><br> // Create a greyscale lookup table<br> vtkSmartPointer<vtkLookupTable> table =vtkSmartPointer<vtkLookupTable>::New();<br> table->SetRange(0, 2000); // image intensity range<br> table->SetValueRange(0.0, 1.0); // from black to white<br> table->SetSaturationRange(0.0, 0.0); // no color saturation<br> table->SetRampToLinear();<br> table->Build();<br> // Map the image through the lookup table<br> vtkSmartPointer<vtkImageMapToColors> color =vtkSmartPointer<vtkImageMapToColors>::New();<br> color->SetLookupTable(table);<br> color->SetInputConnection(reslice->GetOutputPort());<br> // Display the image<br> actor =vtkSmartPointer<vtkImageActor>::New();<br> actor->GetMapper()->SetInputConnection(color->GetOutputPort());<br> <br> vtkSmartPointer<vtkRenderer> renderer =vtkSmartPointer<vtkRenderer>::New();<br> renderer->AddActor(actor);<br> qvtkSlices->GetRenderWindow()->AddRenderer(renderer);<br> vtkSmartPointer<vtkInteractorStyleImage> imageStyle =vtkSmartPointer<vtkInteractorStyleImage>::New();<br> interactor =vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> interactor->SetInteractorStyle(imageStyle);<br><br>qvtkWidget for 3d rendering:<br> qvtkSlices->GetRenderWindow()->SetInteractor(interactor);<br> qvtkSlices->GetRenderWindow()->Render();<br><br> vtkSmartPointer<vtkImageInteractionCallback> callback =vtkSmartPointer<vtkImageInteractionCallback>::New();<br> callback->SetImageReslice(reslice);<br> callback->SetInteractor(interactor);<br> imageStyle->AddObserver(vtkCommand::MouseMoveEvent, callback);<br> imageStyle->AddObserver(vtkCommand::LeftButtonPressEvent, callback);<br> imageStyle->AddObserver(vtkCommand::LeftButtonReleaseEvent, callback);<br> // Start interaction<br> // The Start() method doesn't return until the window is closed by the user<br><br>I don't know why but seems that if I put this the application never loads.<br><br> //interactor->Start(); <br><br>The function that is called when the slider changes is this<br><br>void Ver2D::muestraSlice(int sliceIn)<br>{<br> vtkMatrix4x4 *matrix = reslice->GetResliceAxes();<br> matrix->SetElement(2, 3,matrix->GetElement(2,3)-sliceIn);<br> qvtkSlices->GetRenderWindow()->Render();<br>}<br><br>As you can see I only want to perform a simple translation by changing the value 2,3 of the orientation matrix but when I enter in muestraSlice function the whole application crahes.<br>The reslice pointer is the one created at the begining.<br><br>Where is the problem?? also crashes if I copy the whole sourcecode of the given example (subclasing vtkCommand for initeracting with the image), when entering to MouseMoveEvent:<br><br>else if (event == vtkCommand::MouseMoveEvent)<br> {<br> if (this->Slicing)<br> {<br> vtkImageReslice *reslice = this->ImageReslice;<br> // Increment slice position by deltaY of mouse<br> int deltaY = lastPos[1] - currPos[1];<br> reslice->Update();<br> double sliceSpacing = reslice->GetOutput()->GetSpacing()[2];<br> vtkMatrix4x4 *matrix = reslice->GetResliceAxes();//Puntero a la matriz <br> // move the center point that we are slicing through<br> double point[4];<br> double center[4];<br> point[0] = 0.0;<br> point[1] = 0.0;<br> point[2] = sliceSpacing * deltaY;<br> point[3] = 1.0;<br> matrix->MultiplyPoint(point, center);<br> matrix->SetElement(0, 3, center[0]); <br> matrix->SetElement(1, 3, center[1]);<br> matrix->SetElement(2, 3, center[2]);<br> interactor->Render();<br> }<br><br>If the matrix changes the application crashes. Why? Is there something wrong or I missing something? All works fine except for that.<br><br>Thank you,<br>Nacho N.<br>Virtual Reality and Robotics laboratory Dept.<br><br>                                            </div></body>
</html>