[Insight-users] ITK image origin & VTK world origin

Karthik Krishnan Karthik.Krishnan at kitware.com
Wed Apr 13 09:55:46 EDT 2005


Hi Anders,

VTK has its image origin on the top left as in graphics and ITK has it on the bottom left as in math. VTK +y axis points down, ITK's points up.
A quick look at some of the applications in InsightApplications may help. Several applications in InsightApplications apply ITK filters and have a VTK renderer to visualize the output. 

Here is an excerpt from 

~/work/ITK/src/InsightApplications/SegmentationEditorFltkGui/EditorFltkGui/EditorConsoleBase.cxx
~/work/ITK/src/InsightApplications/SegmentationEditorFltkGui/EditorFltkGui/EditorConsole.cxx

  converter = itk::ImageToVTKImageFilter<SourceImageType>::New();
  flip = itk::FlipImageFilter<SourceImageType>::New();

  SourceAxes[0] = false;
  SourceAxes[1] = true;
  SourceAxes[2] = false;
  
  flip->SetFlipAxes(SourceAxes);
  converter->SetInput(flip->GetOutput());

As Frederic pointed out, you may also manually set the origin by j_new = y_siz - j which is equivalent to flipping.

Or you could go to VTK and then flip with vtkImageFlip

Thanks
Regards
Karthik







Frederic Perez wrote:

>Hello again, Andres,
>
>On 4/12/05, Andres Munarriz <munarriz.a at gmail.com> wrote:
>  
>
>>Hi Frederic,
>>
>>Would you please elaborate on each of the terms involved in your
>>transformation and how to obtain them? I'm not very skillfull in
>>either vtk nor itk.
>>    
>>
>
>Here we go. We've got a MetaImage file containing a CT scan. Our
>goal is to segment a certain anatomical structure by means of a
>command-line program using a region growing filter from ITK 2.0.0.
>That particular filter expects a seed point from which the segmented
>region will grow. We use the method
>"void SetSeed(const IndexType &seed)"---thus we need to provide
>an index.
>
>Now, in order to provide that seed we first visualize the MetaImage
>file with an interactive application on top of VTK 4.4. We use
>vtkImagePlaneWidget objects to query the contents of the file, and
>to obtain a seed index (i_vtk, j_vtk, k_vtk).
>
>Finally, providing that tuple (i_vtk, j_vtk, k_vtk) to SeedSeed didn't
>yield the expected results. Fortunately we found that substituting
>j_vtk by "imgSize[1] - j_vtk - 1" (imgSize[1] being the second
>component of the size of the image) we obtained what we expected.
>Notice that mapping from ITK indices to VTK indices is easy too
>(isolate j_vtk): j_vtk = imgSize[1] - j_itk - 1.
>
>I don't know if this is applicable to your particular problem.
>I apologize if this is not the case.
>
>Cheers,
>
>Frederic Perez
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>
>  
>



More information about the Insight-users mailing list