[vtkusers] Reslice an image with a stencil using a dataset.

David Gobbi david.gobbi at gmail.com
Thu Feb 17 16:10:55 EST 2011


Hi Vincent,

It looks like I didn't understand your original question.  You want to
clip an image with a single finite element, not with a full FEM mesh.
In that case, neither of the methods that I suggested will work.

In your code, I don't see where you are extracting the single element
from your mesh.  Does your mesh contain only one element?

The stencil should be the full size of the output of vtkImageReslice
in this case.  Instead of setting InformationInput, you can directly
call SetOutputOrigin(), SetOutputSpacing(), and SetOutputWholeExtent()
on vtkImplicitFunctionToImageStencil.

But, again, I need to add a disclaimer:  the suggestions I gave you
were for how to generate a stencil from a full mesh, and I really
don't know of a good way to make a stencil from a single element.

 - David





On Thu, Feb 17, 2011 at 1:50 PM, vlibertiaux <vlibertiaux at gmail.com> wrote:
>
> Hi David,
>
> thank you very much for your quick reply.
>
> I have now a better understanding of those classes.
>
> Now, I am still a but confused about how to but everything together.
>
> Let me detail to see if there is a flaw in my reasoning: (I updated the code
> http://codepad.org/TOOpENlx)
>
> my input imagedata, the one I want to clip has an extent of 802*831*514.  I
> want to clip it with a finite element described by the dataset element.
>
> So first I compute the extent corresponding to the element with respect to
> the imagedata.  This extent is a bounding box enclosing the actual finite
> element.  (lines 14->29)
>
> Then I transform the coordinates of the element nodes to fit in the new
> extent (lines 31->50)
>
> I set the vtkImplicitDataSet with the vtkDataSet element, apply the
> previously computed transform and give this ImplicitDataSet as the input of
> the vtkImplicitFunctionToImageStencil (lines 52 ->55).
>
> As far as this latter is concerned, I used the original imagedata as the
> input for SetInformationMethod(). I assumed that the size of the stencil is
> not just the size of the cookie-cutter.  Am I right ?
>
> Finally, I pass data->GetOutpoutPort() as the input for the
> vtkImageReslice->SetInputConnection(), keep the spacing and origin the same
> (I saw you recommended it in a previous post to actually clip an image) and
> apply the stencil.
>
> After those operations, I print the output of the reslice object (through
> GetComponentAsDouble) but I don't have any "2" (my background value),
> meaning that something went wrong.  It is like if the stencil was not
> applied.  Thus, the value enclosed in the bounding box of the finite element
> but not enclosed in this latter are accounted for.
>
> Could you please help me see where did I go wrong ?
>
> Thank you very much,
>
> best regards,
>
> V.
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Reslice-an-image-with-a-stencil-using-a-dataset-tp3390074p3390154.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list