Hello Li,

first of all you do not need to specify a Geometry3D. This should be done by 
the DataNodeFactory for your image correctly. You can access this Geometry by 
simply calling

image->GetGeometry();

You can also try to obtain the PlaneGeometry by calling:

mitk::PlaneGeometry* plane = 
dynamic_cast<mitk::PlaneGeometry*>(image->GetSlicedGeometry(timeStep)->GetGeometry2D(sliceNumber));

Furthermore you need to set ChangeImageGeometryConsideringOriginOffset(FALSE) 
since the your plane is a world geometry which is not related to a image and 
therefor is not center based.

Nevertheless your code seems to be correct.

Have you tried to perform a reinit on your slice when it is loaded in the 
DataManager?

If you want to extract just slices along the standard axes I recommend to use 
simply the mitk::ExtractImageFilter. If you want to extract slices along 
oblique plane you will have to use the 
mitk::ExtractDirectedPlaneImageFilterNew. You can find an example of how the 
ExtractImageFilters are used in the mitkSegTool2D.


Regards
Andreas

On 03.04.2012, at 04:50, Liu, Li wrote:

Hi,

I am trying to use ExtractDirectedPlaneImageFilterNew extract a 2D image from a 
3D image volume (309 547 478). I only can get 2D slice I want along the z-axis 
like I did in following code. If I initialize the slice plane to "Sagittal", 
nothing is shown on rendering window, no matter what number I put in third 
parameter of InitializeStandardPlane. I also tried to rotate the 2D plane to 
some special location, but I found only plane vector in (0,0,1) can generate 
slice image. Does anyone know what is wrong with my operation?


const char * filename = argv[1];

// open data
mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New();
nodeReader->SetFileName(filename);
nodeReader->Update();

// image
mitk::Image::Pointer image = dynamic_cast<mitk::Image*> 
nodeReader->GetOutput()->GetData();

// Spacing
mitk::Vector3D spacing;
spacing.Fill(1.0);

// Origin
mitk::Point3D ori;
ori.Fill(0);

//Bounding box  -  set 309 547 478
mitk::BoundingBox::BoundsArrayType boundingBox;
boundingBox.Fill(0);
boundingBox[1]=image->GetDimension(0);
boundingBox[3]=image->GetDimension(1);
boundingBox[5]=image->GetDimension(2);

//Geometry 3D
mitk::Geometry3D::Pointer geo3D = mitk::Geometry3D::New();
geo3D->SetOrigin(ori);
geo3D->SetIdentity();
geo3D->SetSpacing(spacing);
geo3D->SetBounds(boundingBox);

//Plane
mitk::PlaneGeometry::Pointer planeGeo = mitk::PlaneGeometry::New();
planeGeo->InitializeStandardPlane(geo3D,mitk::PlaneGeometry::PlaneOrientation::Transversal,100);
planeGeo->ChangeImageGeometryConsideringOriginOffset(true);


//filter
mitk::ExtractDirectedPlaneImageFilterNew::Pointer extractFilter = 
mitk::ExtractDirectedPlaneImageFilterNew::New();
extractFilter->SetInput(image);
extractFilter->SetCurrentWorldGeometry2D(planeGeo);
extractFilter->SetImageGeometry(geo3D);
extractFilter->Update();
mitk::Image::Pointer slice = extractFilter->GetOutput();

// rendering
mitk::DataNode::Pointer node = mitk::DataNode::New();
node->SetData(slice);
mitk::StandaloneDataStorage::Pointer DataStorage = 
mitk::StandaloneDataStorage::New();
DataStorage->Add(node);
QmitkRenderWindow* renderWindow = new QmitkRenderWindow(this);
renderWindow->GetRenderer()->SetDataStorage(DataStorage);

Thanks

Li

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to