When extracting a 2D Plane with the filter, using the geometry of an renderwindow, the resulting plane is slightly dislocated. e.g. When i extract a normal transversal slice from Pic3D, the image is moved to lower left and on the upper right a "border" is created (See attached image). This also happens when i extract some rotated plane.
I used the following code to extract the slice:
mitk::Image::Pointer image; for (int i=0; i<this->GetDataManagerSelection().size(); i++) { mitk::DataNode::Pointer node = this->GetDataManagerSelection().at(i); image = dynamic_cast<mitk::Image *>( node->GetData()); } // Cut plane and store in vector mitk::ExtractDirectedPlaneImageFilterNew::Pointer extractFilter = mitk::ExtractDirectedPlaneImageFilterNew::New(); extractFilter->SetInput(image); extractFilter->SetActualInputTimestep( 0 ); extractFilter->SetCurrentWorldGeometry2D( this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetSliceNavigationController()->GetCurrentPlaneGeometry() ); extractFilter->Modified(); extractFilter->Update(); mitk::Image::Pointer image2D = extractFilter->GetOutput(); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(image2D); GetDataStorage()->Add(node);
in mitkExtractDirectedPlaneImageFilterNew.cpp line 120
it says
Point3D origin = m_CurrentWorldGeometry2D->GetOrigin();
but when i change it to
Point3D origin = m_CurrentWorldGeometry2D->GetOrigin() - (m_CurrentWorldGeometry2D->GetSpacing() * 0.5) ;
everything works fine. I can extract a arbitary rotated slice. So the issue is a 0.5 offset. However, the 3D interpolation is not working so nicely anymore, when i do this.
What do you think, Andreas?
Should I change that line and you adapt the 3D interpolation? Or is the PlaneExtraction working as it should and i am just using it worng (maybe i should prepare the input geometry a little first..)