<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<pre wrap="">Dear Insight-users,

Thank you very much for your answer. That clarified things.
My earlier post about the origin was incorrect, ITK's origin at the top left, VTK's at the bottom left. 

A quick look at the code cleared things up.

vtkPNGWriter.cxx:
  for (ui = 0; ui &lt; height; ui++)
    {
    row_pointers[height - ui - 1] = (png_byte *)outPtr;
    outPtr = (unsigned char *)outPtr + rowInc;
    }
  png_write_image(png_ptr, row_pointers);

itkPNGIMageIO.cxx
  for (unsigned int ui = 0; ui &lt; height; ui++)
    {
    row_pointers[ui] = (png_byte *)outPtr;
    outPtr = const_cast&lt;unsigned char *&gt;(outPtr) + rowInc;
    }
  png_write_image(png_ptr, row_pointers);
 
And since raw pointers are passed across by ImageToVTKFilter, flipping is needed. 

Thanks again and sorry about the confusion
Regards
Karthik 
</pre>
<br>
Lorensen, William E (Research) wrote:
<blockquote
 cite="midB744015F9200AA49B4E03549EED88B9801D8F994@SCHMLVEM01.e2k.ad.ge.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <title></title>
  <meta content="MSHTML 6.00.2800.1491" name="GENERATOR">
  <div><span class="785521312-14042005"><font color="#0000ff"
 face="Arial" size="2">Karthik,</font></span></div>
  <div><span class="785521312-14042005"><font color="#0000ff"
 face="Arial" size="2">Your explanation of origin is reversed. ITK's
first byte on disk is origin, y goes down. This is the natural way to
represent images. vtk, uses the computer graphics convention. The first
byte of the last row&nbsp; on disk is the first byte on memory.</font></span></div>
  <div><span class="785521312-14042005"><font color="#0000ff"
 face="Arial" size="2">Each system has different requirements
unfortunately.</font></span></div>
  <div><span class="785521312-14042005"></span>&nbsp;</div>
  <div><span class="785521312-14042005"><font color="#0000ff"
 face="Arial" size="2">Users need to flip the vertical axis to get the
vtk and itk images aligned.</font></span></div>
  <div><span class="785521312-14042005"></span>&nbsp;</div>
  <div><span class="785521312-14042005"><font color="#0000ff"
 face="Arial" size="2">Bill</font></span></div>
  <blockquote>
    <div class="OutlookMessageHeader" align="left" dir="ltr"><font
 face="Tahoma" size="2">-----Original Message-----<br>
    <b>From:</b> Karthik Krishnan [<a class="moz-txt-link-freetext" href="mailto:Karthik.Krishnan@kitware.com">mailto:Karthik.Krishnan@kitware.com</a>]<br>
    <b>Sent:</b> Wednesday, April 13, 2005 11:51 AM<br>
    <b>To:</b> Blezek, Daniel J (Research)<br>
    <b>Cc:</b> Lorensen, William E (Research); Miller, James V
(Research); Luis Ibanez (E-mail)<br>
    <b>Subject:</b> Re: [Insight-users] ITK image origin &amp; VTK
world origin<br>
    <br>
    </font></div>
    <pre wrap="">Hi Dan,

Actually I was just pondering on the comment I just made. Frankly I am still confused. Here is a small test and the CMakeLists.txt file. The test just creates a box spatial object at (0,0) and another one translated by (15,15) and writes it using an ITK writer. Then it uses the ImageToVTKImageFilter and writes it using the vtkPNGWriter.

The two images are flipped.

&gt;From the ITK Software guide which says that the origin is at the bottom left, y axis going upwards, which I believe is correct. My understanding is that the origin is that index which points to first location in memory where the image is stored and since PNG writers read from the first location and write out in a ComputerGraphics convention, they write it out upside down. And images need to be flipped while passing from ITK to VTK.

Maybe I've got all my concepts screwed up. Please let me know. 

Thanks
Regards
karthik

PS: This is last weeks build (before the OrientedImage class was added last night, but after the change was made to the writers about flipping on Y.)



    </pre>
    <br>
Blezek, Daniel J (Research) wrote:
    <blockquote
 cite="midB744015F9200AA49B4E03549EED88B9801E64BA0@SCHMLVEM01.e2k.ad.ge.com"
 type="cite">
      <pre wrap="">Karthik,  Is this documented somewhere in ITK?  I believe this is an ad hoc standard for ITK.  If it were truely a standard, the readers would all need to be made consistent.  As I understand it, the readers put the first byte on disk into the first byte of the volume.

Oriented Image will take care of this issue, and the VTK / ITK interface will need to be looked at.

-dan

-----Original Message-----
From: <a class="moz-txt-link-abbreviated"
 href="mailto:insight-users-bounces@itk.org">insight-users-bounces@itk.org</a>
[<a class="moz-txt-link-freetext"
 href="mailto:insight-users-bounces@itk.org">mailto:insight-users-bounces@itk.org</a>]On Behalf Of Karthik Krishnan
Sent: Wednesday, April 13, 2005 9:56 AM
To: Frederic Perez
Cc: <a class="moz-txt-link-abbreviated"
 href="mailto:insight-users@itk.org">insight-users@itk.org</a>; Andres Munarriz
Subject: Re: [Insight-users] ITK image origin &amp; VTK world origin


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&lt;SourceImageType&gt;::New();
  flip = itk::FlipImageFilter&lt;SourceImageType&gt;::New();

  SourceAxes[0] = false;
  SourceAxes[1] = true;
  SourceAxes[2] = false;
  
  flip-&gt;SetFlipAxes(SourceAxes);
  converter-&gt;SetInput(flip-&gt;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:

  </pre>
      <blockquote type="cite">
        <pre wrap="">Hello again, Andres,

On 4/12/05, Andres Munarriz <a class="moz-txt-link-rfc2396E"
 href="mailto:munarriz.a@gmail.com">&lt;munarriz.a@gmail.com&gt;</a> wrote:
 

    </pre>
        <blockquote type="cite">
          <pre wrap="">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.
   

      </pre>
        </blockquote>
        <pre wrap="">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 &amp;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
<a class="moz-txt-link-abbreviated" href="mailto:Insight-users@itk.org">Insight-users@itk.org</a>
<a class="moz-txt-link-freetext"
 href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>

 

    </pre>
      </blockquote>
      <pre wrap=""><!---->
_______________________________________________
Insight-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Insight-users@itk.org">Insight-users@itk.org</a>
<a class="moz-txt-link-freetext"
 href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>

  </pre>
    </blockquote>
    <br>
  </blockquote>
</blockquote>
<br>
</body>
</html>