[vtkusers] Readers read image with some kind of reveral?

David Gobbi david.gobbi at gmail.com
Tue Apr 16 17:30:34 EDT 2013


On Tue, Apr 16, 2013 at 10:17 AM, David Doria <daviddoria at gmail.com> wrote:
> On Tue, Apr 16, 2013 at 11:45 AM, ChenDawnWind <cybfly1 at hotmail.com> wrote:
>> Hi everyone,
>> when i use the reader such as vtkJPEGReader to read one image file(see
>> attachment) and extract the contour of
>> the img, then read the result output and print the points with OpenCV.
>> Then i found the image was not the way it used to be.
>> In the attachment the original image is number 1, and the contour image is
>> number 2.
>> It is clear that the image reversal in some way.
>> Cause i have to set the point of the contour in the 3D model,
>> with this revesal the calculated center of the white target in the the
>> original image was not suit the reveral image 2.
>> So i wanna know is there any way to avoid this revesal and to read file as
>> it used to be?
>> Thanks!
>>
>> DawnWind.Chen
>> CSU
>
>
> It looks to me like you are just viewing the points from a different
> viewpoint. If you want to change the view on the VTK side of things,
> check out:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/vtkCamera
>
> for how to position and aim the camera.
>
> David

I don't think this is a camera issue.  The vtkJPEGReader does in fact
flip the image.  In JPEG the first pixel is at the upper left corner
of the image, while VTK's 2D coordinate system (the one used for
vtkActor2D) has the first pixel at the lower left corner of the
renderer.  The reader flips the image so that it appears the right way
up on the screen when displayed with vtkImageViewer.  This flip of
course means that the coordinates of any points that you get from
contouring the image will be flipped top-to-bottom.

For some readers, you can call FileLowerLeftOn() to stop the reader
from flipping the image.

 - David



More information about the vtkusers mailing list