Pixel origin convention
This page follow the status of the pixel convention used in OTB and other libraries such as GDAL. In addition, several filters need an update so that they are consistent with the convention chosen in OTB.
The dilemma
The georeferencing of images can be done by simply using an origin and a spacing. There are two major convention to link the physical space (ground coordinates) and the index space (indices coordinates) :
- Pixel centred origin : the origin point corresponds to the location of the centre of the top-left pixel.
- Corner origin : the origin point corresponds to the location of the top-left corner of the top-left pixel.
Which conventions are used ?
The pixel centred convention is used in OTB and ITK. Note that in older ITK versions ( before 4.0 ), both conventions were supported, using a compilation flag. At the moment, the goal is to use this convention everywhere in the OTB.
In GDAL, the corner origin convention is used. For instance, the geotransform given by GDAL is expressed in this convention : the terms GT(0) and GT(3) corresponds to the coordinates of the top-left corner of the image (regardless of the type of pixel : area or point).
Filters to update
This section list the filters that need an update. When the update has been done, struck out the name and give the corresponding commit. The line numbers given refer to changeset 16837. The corresponding Mantis bug is 942 : http://bugs.orfeo-toolbox.org/view.php?id=942
The first filters to update are the ImageIO's.
IO/ImageIO
These filters use the geotransform given by GDAL :
-
Code/IO/otbGDALImageIO.cxx(http://hg.orfeo-toolbox.org/OTB/rev/c3f3fe14bfde) -
Code/IO/otbJPEG2000ImageIO.cxx(http://hg.orfeo-toolbox.org/OTB/rev/c12e6b03cb99)
The other ImageIOs have been updated to use a default origin at [0.5 , 0.5] to ensure consistency when reading/writing from 2 differents ImageIOs. (http://hg.orfeo-toolbox.org/OTB/rev/b5611cea6168)
-
Code/IO/otbBSQImageIO.cxx -
Code/IO/otbLUMImageIO.cxx -
Code/IO/otbMSTARImageIO.cxx -
Code/IO/otbMWImageIO.cxx -
Code/IO/otbONERAImageIO.cxx -
Code/IO/otbRADImageIO.cxx -
Code/IO/otbTileMapImageIO.cxx
Several OTB filters have been written using the corner-pixel convention. They are sorted by category. Some of them have been reviewed without any modification to do. If filters have not been spotted so far, they will be added.
Common
-
Code/Common/otbVectorDataToImageFilter.txx: see line 407 , should use the correct physical envelope to extract vector data (http://hg.orfeo-toolbox.org/OTB/rev/0363d478697e) -
Code/Common/otbOGRDataSourceToLabelImageFilter.txx: see line 213, Convert to geotransform like it is done in GDALImageIO (http://hg.orfeo-toolbox.org/OTB/rev/0363d478697e) -
Code/Common/otbVectorDataToMapFilter.txx: see line 404, Same as otbVectorDataToImageFilter.txx (http://hg.orfeo-toolbox.org/OTB/rev/0363d478697e) -
Code/Common/otbLabelImageToOGRDataSourceFilter.txx: see line 189 & 259, convert to geotransform properly (http://hg.orfeo-toolbox.org/OTB/rev/94a439e610d7) -
Code/Common/otbPolyLineImageConstIterator.txx: see the translation between vertex coordinates (assumed in continuous index) and real index used by the internal iterator (source and target). The rounding was missing : e.g. vertex coordinates between 3.5 and 4.5 should give the index value 4. (http://hg.orfeo-toolbox.org/OTB/rev/678453a0e5b7)
BasicFilters
-
Code/BasicFilters/otbSpatialObjectToImageDrawingFilter.txx: see line 302, Bounding box to origin conversion (http://hg.orfeo-toolbox.org/OTB/rev/df92d696fa1b) -
Code/BasicFilters/otbVectorDataToLabelImageFilter.txx: see line 291, Convert to geotransform like it is done in GDALImageIO (http://hg.orfeo-toolbox.org/OTB/rev/df92d696fa1b) -
Code/BasicFilters/otbLabelImageToVectorDataFilter.txx: see line 167 & 237, same pb with geotransform as the previous filter. (http://hg.orfeo-toolbox.org/OTB/rev/0cc559c94192) -
Code/BasicFilters/otbRasterizeVectorDataFilter.txx: see line 177, convert to geotransform properly (http://hg.orfeo-toolbox.org/OTB/rev/94a439e610d7) -
Code/BasicFilters/otbStreamingShrinkImageFilter.txx: see line 136, the output origin should be adapted as well (http://hg.orfeo-toolbox.org/OTB/rev/205374698b81)
Projection
-
Code/Projections/otbImageToEnvelopeVectorDataFilter.txx: Compute real image extent (http://hg.orfeo-toolbox.org/OTB/rev/f395491b3550) -
Code/Projections/otbImageToGenericRSOutputParameters.txx: Compute real image extent (http://hg.orfeo-toolbox.org/OTB/rev/73069cbebe21) -
Code/Projections/otbVectorDataIntoImageProjectionFilter.txx: see line 137, bounding box (http://hg.orfeo-toolbox.org/OTB/rev/73069cbebe21)
DisparityMap
-
Code/DisparityMap/otbDisparityMapToDEMFilter.txx: bounding box computation (http://hg.orfeo-toolbox.org/OTB/rev/871fa71cf412) -
Code/DisparityMap/otbMulti3DMapToDEMFilter.txx: bounding box computation (http://hg.orfeo-toolbox.org/OTB/rev/871fa71cf412) -
Code/DisparityMap/otbBijectionCoherencyFilter.txx: reviewed, nothing to do -
Code/DisparityMap/otbStereoSensorModelToElevationMapFilter.txx: reviewed, nothing to do -
Code/DisparityMap/otbDisparityTranslateFilter.txx: bounding box computation (http://hg.orfeo-toolbox.org/OTB/rev/871fa71cf412) -
Code/DisparityMap/otbStereorectificationDisplacementFieldSource.txx: reviewed, nothing to do
IO
-
Code/IO/otbMapFileProductWriter.txx: see line 374, bounding box (http://hg.orfeo-toolbox.org/OTB/rev/bcb9373e931a) -
Code/IO/otbKmzProductWriter.txx: see line 495, bounding box (http://hg.orfeo-toolbox.org/OTB/rev/bcb9373e931a) -
Code/IO/otbImageFileReader.txx: see line 425, set default origin to 0.5 when no carto is used (http://hg.orfeo-toolbox.org/OTB/rev/bcb9373e931a) - Code/IO/otbTileMapImageIO.cxx : see line 660, TBC
OBIA
-
Code/OBIA/otbLabelObjectToPolygonFunctor.txx: see line 550, Check methods WalkRight and WalkLeft, the computed offset should be between -0.5 and 0.5 (http://hg.orfeo-toolbox.org/OTB/rev/71079039f02b) -
Code/OBIA/otbVectorDataToLabelMapWithAttributesFilter.txx: see line 145, Origin computed doesn"t takes into account the centered pixel convention, the filter assumes that vector data contains index coordinates values, see line 330 : Beware of confusion between bounding region and image origin (http://hg.orfeo-toolbox.org/OTB/rev/71079039f02b)
MultiScale
-
Code/MultiScale/otbMorphologicalPyramidResampler.txx: see line 145, the resampler keep the same origin between 2 pyramid levels, the transform used only accounts for the scale factor (http://hg.orfeo-toolbox.org/OTB/rev/2817106a9681). Now, with a factor 2 resampling, each resampled pixel equals the average of the corresponding block of 4 neighbours in the input image.
Segmentation
-
Code/Segmentation/otbOGRLayerStreamStitchingFilter.txx: see line 142 and after, the computation of the stream line in physical space doesn't correspond to the centred pixel convention. Also the computation of the spatial filters (line 164 and 208) seems inaccurate. (http://hg.orfeo-toolbox.org/OTB/rev/50c90708cd89) Now, the test obTuOGRLayerStreamStitchingFilter passes using the original baseline.
FeatureExtraction
-
Code/FeatureExtraction/otbGenericRoadExtractionFilter.txx: obviously a bug, the m_Resolution parameter is never updated. Since the sigma value used by the gradient filter is constant in pixel units, let's use this unit in the gradient filter. (see http://hg.orfeo-toolbox.org/OTB/rev/42017ce0477b). The corresponding test (feTvRoadExtractionFilter) had 5 multi-baselines. One of them had comparable results to what is produced now. All multi-baselines have been removed, the present baseline has been updated.
Applications/Projections
-
Applications/Projections/otbOrthoRectification.cxx: Use 'ulx' , 'uly', 'lrx' 'lry' as real image corners , conversion with origin imply half a pixel shift (http://hg.orfeo-toolbox.org/OTB/rev/3a94697b06b5) -
Applications/Projections/otbRigidTransformResample.cxx: fix output physical space after transform (http://hg.orfeo-toolbox.org/OTB/rev/08b25841dfa6)
Applications/Utils
-
Applications/Utils/otbVectorDataExtractROI.cxx: Use real image corners (http://hg.orfeo-toolbox.org/OTB/rev/53b6813ee642)
Applications/FeatureExtraction
-
Applications/FeatureExtraction/otbHomologousPointsExtraction.cxx: fix computation of opposite region (http://hg.orfeo-toolbox.org/OTB/rev/c1926a666a89)
Applications/Rasterization
-
Applications/Rasterization/otbRasterization.cxx: fix computation of output extent (http://hg.orfeo-toolbox.org/OTB/rev/04ebf61abd7f)
TODO