(VTK): 2D images are flipped
Description
VTK axis are not the same as the other libraries like openCV (see http://whimsandfancies1897.blogspot.com/2014/10/coordinate-and-colour-channel.html) VTK image origin is on bottom-left while openCV origin is on top-left. So wen you convert the image from VTK to openCV it must be flipped.
VTK 2D Image readers/writers
- VTK 2D image writers (
vtkPNGWriter
,vtkBMPWriter
,vtkPNMWriter
,vtkTIFFWriter
andvtkJPEGWriter
) flip the image when saving. - VTK 2D image readers (
vtkPNGReader
,vtkBMPReader
,vtkPNMReader
, andvtkJPEGReader
) flip the image when loading, but notvtkTIFFWriter
.
It works when the image is resulting from a vtk algorithm, but we cannot ensure that the image we want to save is in the VTK coordinate system.
vtkJPEGWriter
may change the image value due to the compresion.
Image conversion
All the 3D images readers/writers used in sight seems to use the same origin coordinates (VTK ?)
Offscreen rendering from VTK should be flip before to use it on openCV algorithm (done with a XML option), but Ogre offscreen rendering return an image with the same origin as openCV.
Steps to reproduce
Try to save a 2D image using VTK
with an extension '.png', '.jpg', '.tiff', ...
You can use this code to test the readers/witers.
Proposal
We should define the origin of a ::fwData::Image
, and it should be the same for 2D and 3D image. Then, we should refactor the conversion from a ::fwData::Image
to an image in the different external libraries (VTK, Ogre, openCV, ITK).
Functional specifications
The VTK writers were removed in !792 (merged). We should replace them everywhere by using the new sight::module::io::bitmap
.
Technical specifications
Use directly sight::module::io::bitmap::SWriter
for image screenshots, instead of relying on module::io::SSelector
.
Test plan
Test the affected applications.