ImageFileReader status

From OTBWiki
Revision as of 16:18, 20 April 2011 by MickaelS (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page tries to summarize the current status of the ImageFileReader data conversion.

When an input file is read, different operations can take place to fit in the output image type. The following aspects have an impact:

  • the pixel type of the input file (char, short, int, float, double, complex<short>, complex<int>, complex<float>, complex<double>)
  • the number of bands of the input file (monoband or multiband, but specific conversion are done for 2, 3 and 4 bands)
  • the image class used in the template parameter of ImageFileReader (otb::Image or otb::VectorImage)
  • the pixel type of the image class used in the template parameter of ImageFileReader

The main classes involved under the hood are :

  • ImageFileReader
  • ConvertPixelBuffer
  • the different ImageIO


Reading a monoband scalar image

into otb::Image<scalar>

  • Nominal case.
  • The proper type conversion is used to convert from the input file pixel type to the output pixel type.
  • In case of overflow, what happens ?

into otb::Image<complex>

  • out.real = in
  • out.imag = 0

into otb::VectorImage<scalar>

  • Nominal case
  • output is a one-band VectorImage

into otb::VectorImage<complex>

  • output is a one-band VectorImage
  • out[0].real = in
  • out[0].imag = 0


Reading a multiband scalar image

into otb::Image<scalar>

  • input file has 2 bands : out = in[0] * in[1], assuming the second band is an alpha channel
  • input file has 3 bands : ITK does the conversion by applying weights to convert from linear RGB to CIE luminance
  • input file has 4 bands : ITK does the conversion by applying weights to convert from linear RGB to CIE luminance with the first 3 channels. The 4th channel is used as an alpha channel and is multiplied to the result.
  • input file has >4 bands : only the first 4 channels are used, assuming RGBA representation
  • SHOULD BE FIXED : for geospatial products, 3/4 bands does not usually mean RGB/RGBA. Using a common behavior might be better (mean of all bands?)

into otb::Image<complex>

  • only the first 2 bands are used
  • out.real = in[0]
  • out.imag = in[1]

into otb::VectorImage<scalar>

  • Nominal case

into otb::VectorImage<complex>

  • number of bands of output = number of bands of input
  • out[k].real = in[k]
  • out[k].imag = 0
  • SHOULD BE FIXED : currently, there is a segfault when reading float into VectorImage<std::complex<double>>, and when reading double into VectorImage<std::complex<float>>
  • FIXED

Reading a monoband complex image

into otb::Image<scalar>

  • out = abs(in)

into otb::Image<complex>

  • Nominal case

into otb::VectorImage<scalar>

  • 2 bands
  • out[0] = in.real
  • out[1] = in.imag

into otb::VectorImage<complex>

  • 1 band
  • out[0] = in


Reading a multiband complex image

into otb::Image<scalar>

  • NOT SUPPORTED
  • SHOULD BE FIXED : need a spec (what to do ? throw exception ?)

into otb::Image<complex>

  • NOT SUPPORTED
  • SHOULD BE FIXED : need a spec (what to do ? throw exception ?)

into otb::VectorImage<scalar>

  • output number of bands = 2 * input number of bands
  • out[2k] = in[k].real
  • out[2k+1] = in[k].imag

into otb::VectorImage<complex>

  • Nominal case


Misc

  • Complex_int and complex_short GDAL types are supported.