Hi Felix, it is always difficult to work with rotated geometries. Especially if this involves the reconstruction of a certain PlaneGeometry since rounding errors are most likely to occur. Looking at your code again I noticed some other things (which may possibly be the cause of such rounding errors):
First of all the directions of the vectors which you calculate are wrong (at least according to their names). The "rightToCenter" is according to your calculation a "centerToRight" (analogous for the other one) But this is probably not a problem :-) Another point is that the normal which is calculated for the transversal plane (this is done in the InitialesPlanes function) points in the wrong direction. For the call of InitializePlane the two vectors should be switched. Finally I was wondering how you define the three points of your "T". This could be another possible source for rounding errors e.g. if these point do not lie exactly on the plane. Regards Andreas On 14.01.2013, at 18:20, Félix C. Morency wrote: > Hi Andreas, > > Thank you for your suggestions. > > Sadly, not setting the bounds of the plane gives me a 1 voxel "plane" [1] and > not setting the spacing in the plane initialization gives me the exact same > problem (holes). In the mean time, I wrote my own plane writer using > PlaneGeometry, Geometry3D and ITK (AccessByItk*). Although, I really want to > know why it doesn't work with the mitkVtkImageOverwrite. > > [1]: http://imgur.com/64dc1 > > -F > > > On Mon, Jan 14, 2013 at 11:42 AM, Fetzer, Andreas > <[email protected]> wrote: > Hi Felix, > > I noticed two thing in your code: > > First of all you are setting the spacing of your original image to the plane. > This could be a problem since the spacing is recalculated in case of a > rotated image volume. > Next thing is that you are setting the bounds of the original image which > also could be a problem since the bounds of the plane are changed either > after a rotation. > > You can try the following for plane initialization: > > cutterPlaneTopRight->InitializeStandardPlane(rightToCenter, down); > cutterPlaneTopRight->SetOrigin(p1); > > without setting the bounds. > > Regards > Andreas > > > > On 14.01.2013, at 16:11, Félix C. Morency wrote: > > > Andreas, > > > > Thank you for your anwser, The solution in WriteBackSegmentationResult is > > great if you PlaneGeometry is aligned with the current axis. However, this > > is not my case. > > > > I define my PlaneGeometry from a T-shaped targed placed in the sagittal > > view [1]. The plane you see is created using > > > > mitk::Point3D p1 = figure->GetWorldControlPoint(0); > > mitk::Point3D p2 = figure->GetWorldControlPoint(1); > > mitk::Point3D center2D = figure->GetWorldControlPoint(2); > > > > //1.1 Setup direction vectors > > mitk::Vector3D rightToCenter = p2 - p1; > > mitk::Vector3D centerToTop = p1 - center2D; > > centerToTop.Normalize(); > > rightToCenter.Normalize(); > > > > mitk::Vector3D down = itk::CrossProduct(centerToRight, > > centerToTop); > > down.Normalize(); > > > > //1.2 Initialize the planes > > mitk::PlaneGeometry::Pointer cutterPlaneTopRight = > > mitk::PlaneGeometry::New(); > > > > cutterPlaneTopRight->InitializeStandardPlane(rightToCenter, > > down, &image->GetGeometry()->GetSpacing()); > > cutterPlaneTopRight->SetOrigin(p1); > > cutterPlaneTopRight->SetBounds(image->GetGeometry()->GetBounds()); > > > > > > where center2D is the top-most point in the image, p2 is the right-most > > point and p1 is the intersection point of the T. As you can see, the plane > > creation works just fine. The plane creation also works if the target is > > rotated [2]. > > > > However, if the axis of the volume are rotated, the plane has holes in it > > [3] even if the target itself is not rotated. The plane creation is done > > using > > > > mitk::ExtractSliceFilter::Pointer slicer = > > mitk::ExtractSliceFilter::New(); > > slicer->SetInput(image); > > slicer->SetWorldGeometry(cutterPlaneTopRight); > > slicer->SetVtkOutputRequest(true); > > slicer->Modified(); > > slicer->Update(); > > > > vtkSmartPointer<vtkImageData> sliceTopRight = > > vtkSmartPointer<vtkImageData>::New(); > > sliceTopRight = slicer->GetVtkOutput(); > > > > int* dims = sliceTopRight->GetDimensions(); > > for (int z = 0; z < dims[2]; ++z) > > { > > for (int y = 0; y < dims[1]; ++y) > > { > > for (int x = 0; x < dims[0]; ++x) > > { > > sliceTopRight->SetScalarComponentFromDouble(x,y,z,0,1.0); > > } > > } > > } > > > > vtkSmartPointer<mitkVtkImageOverwrite> resliceIdx = > > vtkSmartPointer<mitkVtkImageOverwrite>::New(); > > resliceIdx->SetOverwriteMode(true); > > resliceIdx->SetInputSlice(sliceTopRight); > > resliceIdx->Modified(); > > > > mitk::ExtractSliceFilter::Pointer overwriter = > > mitk::ExtractSliceFilter::New(resliceIdx); > > overwriter->SetInput(image); > > overwriter->SetWorldGeometry(cutterPlaneTopRight); > > overwriter->SetVtkOutputRequest(true); > > overwriter->Modified(); > > overwriter->Update(); > > > > [1]: http://imgur.com/RPTo2 > > [2]: http://imgur.com/JXFyx > > [3]: http://imgur.com/j05lH > > > > Regards, > > -F > > > > > > On Mon, Jan 14, 2013 at 3:43 AM, Fetzer, Andreas > > <[email protected]> wrote: > > Hi Felix, > > > > how do you get the PlaneGeometry which is set for writing the slice? You > > should retrieve the according PlaneGeometry like it is done e.g. in the > > mitkSegTool2D::WriteBackSegmentationResult. If this doesn't solve your > > problem it would be helpful if you could post your code here. > > > > Regards > > Andreas > > > > On 11.01.2013, at 21:15, Félix C. Morency wrote: > > > > > Hi list, > > > > > > I am trying to overwrite a slice of arbitrary orientation in a volume and > > > I'm facing some issues. I based my code on the > > > mitkOverwriteSliceFilterObliquePlaneTest. When my axis planes are > > > oriented by default (axial/coronal/sagittal), everything's going fine and > > > the slice is written properly [1]. > > > > > > However, if I change the plane orientations using the coupled crosshair > > > rotation tool, my slice is full of holes [2]. I tried playing with > > > SetInPlaneResampleExtentByGeometry and with SetResliceTransformByGeometry > > > without any luck. My initial guess is that it has something to do with > > > slice sampling and current geometry. Does anyone have a clue on how to > > > solve my problem? The objective is to fill the entire slice with the same > > > value. > > > > > > [1]: http://imgur.com/Ru4Nm > > > [2]: http://imgur.com/FzCwx > > > > > > Regards, > > > -- > > > Félix C. Morency, M.Sc. > > > Plateforme d’analyse et de visualisation d’images > > > Centre Hospitalier Universitaire de Sherbrooke > > > Centre de recherche clinique Étienne-Le Bel > > > Local Z5-3031 | 819.346.1110 ext 16634 > > > ------------------------------------------------------------------------------ > > > Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and > > > much more. Get web development skills now with LearnDevNow - > > > 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > > > SALE $99.99 this month only -- learn more at: > > > http://p.sf.net/sfu/learnmore_122812_______________________________________________ > > > mitk-users mailing list > > > [email protected] > > > https://lists.sourceforge.net/lists/listinfo/mitk-users > > > > > > > > > > -- > > -- > > Félix C. Morency, M.Sc. > > Plateforme d’analyse et de visualisation d’images > > Centre Hospitalier Universitaire de Sherbrooke > > Centre de recherche clinique Étienne-Le Bel > > Local Z5-3031 | 819.346.1110 ext 16634 > > > > > -- > -- > Félix C. Morency, M.Sc. > Plateforme d’analyse et de visualisation d’images > Centre Hospitalier Universitaire de Sherbrooke > Centre de recherche clinique Étienne-Le Bel > Local Z5-3031 | 819.346.1110 ext 16634 ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712 _______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users
