Bug in Pansharpening?

I’m pansharpening a multi-spectral image with a panchromatic image and get:

2019 Jan 24 11:57:30 : Application.logger (FATAL) The following error occurred during OTB-application execution: /home/mrashad/dashboard/otb/install-stable/include/ITK-4.10/itkImageToImageFilter.hxx:250:
itk::ERROR: SimpleRcsPanSharpeningFusionImageFilter(0x7f67e4058170): Inputs do not occupy the same physical space!
InputImage Origin: [1.0000000e+01, -1.0000000e+01], InputImage_1 Origin: [5.0000000e-01, -5.0000000e-01]
Tolerance: 2.0000000e-05
InputImage Spacing: [2.0000000e+01, -2.0000000e+01], InputImage_1 Spacing: [1.0000000e+00, -1.0000000e+00]
Tolerance: 2.0000000e-05

Novertheless, both images overlap in Monteverdi and gdalinfo outputs the very identical location, the only difference being pixel size:

Origin = (0.000000000000000,0.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 0.0000000, 0.0000000) ( 1d29’19.48"W, 0d 0’ 0.01"N)
Lower Left ( 0.000, -1000.000) ( 1d29’19.48"W, 0d 0’32.47"S)
Upper Right ( 1000.000, 0.000) ( 1d28’47.23"W, 0d 0’ 0.01"N)
Lower Right ( 1000.000, -1000.000) ( 1d28’47.23"W, 0d 0’32.47"S)
Center ( 500.000, -500.000) ( 1d29’ 3.35"W, 0d 0’16.23"S)

Origin = (0.000000000000000,0.000000000000000)
Pixel Size = (20.000000000000000,-20.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 0.0000000, 0.0000000) ( 1d29’19.48"W, 0d 0’ 0.01"N)
Lower Left ( 0.000, -1000.000) ( 1d29’19.48"W, 0d 0’32.47"S)
Upper Right ( 1000.000, 0.000) ( 1d28’47.23"W, 0d 0’ 0.01"N)
Lower Right ( 1000.000, -1000.000) ( 1d28’47.23"W, 0d 0’32.47"S)
Center ( 500.000, -500.000) ( 1d29’ 3.35"W, 0d 0’16.23"S)

Is this a bug in PanSharpening?

Thanks

Hi Alobo,
Unfortunately your images are indeed not in the same physical space. In the case of PanSharpening you only need to have the same origin, which you do not have. Gdal is saying that you have the same origin because you have the same upper left corner (physical). For OTB, the origin is the center of the upper left pixel…

According to gdal, both have the same upper left pixel:
Upper Left ( 0.0000000, 0.0000000) ( 1d29’19.48"W, 0d 0’ 0.01"N)

Obviously, if the images have different resolution (as it must be the case for any pansharpening…) the
center of the upper-left pixel is never going to be the same!

Agus

Yes that is what I was trying to explain, OTB needs their center (origin) to be the same… You should use BundleToPerfectSensor.
See Difference between otbcli_pansharpening and otbcli_BundleToPerfectSensor?

Pansharpening does not handle up-sampling of XS channels. It expects perefctly registered pan and xs images (same origin, spacing and size). If you want that you need to use BundleToPerfectSensor, which will perform upsampling first and then pan-sharpening.

ok, the link explains everything, thanks. But then, as far as I understand it, the current otbcli_Pansharpening should actually not exist (or be renamed consistently with whatever it does) and otbcli_BundleToPerfectSensor should be renamed to otbcli_Pansharpening, because that’s what the user is going to use it for.
The current situation is:

  1. An otbcli_Pansharpening that performs P+XS pansharpening but that, in fact, cannot work
  2. An otbcli_BundleToPerfectSensor that is actually doing pansharpening but hides under an inextricable name.

And, in both cases, the doc states This application performs P+XS pansharpening

Not really. In the litterature I think pan-sharpening per se is the family of algorithm that mixes pan and up-sampled xs channels. You may want ot use that only and handle your resampling somewhere else.

1 Like

We could also have a single application and have an option to resample xs before sharpening. Why not.

We might have to briefly review the literature, but from the term, “pan”-“sharp” implies increasing the resolution of an image using a panchromatic image of higher resolution. It’s ok keeping 2 steps,
but I think that the whole chain should be called “Pansharpening” and each step should get an appropriate name.
Also, I note that the 3 options available in the current otbcli_Pansharpening application are not available in otbcli_BundleToPerfectSensor, why?

PanSharpening

Complete documentation: https://www.orfeo-toolbox.org/CookBook/Applications/app_Pansharpening.html or -help

Parameters: 
MISSING -inp                 <string>         Input PAN Image  (mandatory)
MISSING -inxs                <string>         Input XS Image  (mandatory)
MISSING -out                 <string> [pixel] Output image  [pixel=uint8/uint16/int16/uint32/int32/float/double/cint16/cint32/cfloat/cdouble] (default value is float) (mandatory)
        -method              <string>         Algorithm [rcs/lmvm/bayes] (mandatory, default value is rcs)
        -method.lmvm.radiusx <int32>          X radius  (mandatory, default value is 3)
        -method.lmvm.radiusy <int32>          Y radius  (mandatory, default value is 3)
        -method.bayes.lambda <float>          Weight  (mandatory, default value is 0.9999)
        -method.bayes.s      <float>          S coefficient  (mandatory, default value is 1)
        -ram                 <int32>          Available RAM (MB)  (optional, off by default, default value is 128)
        -inxml               <string>         Load parameters from XML  (optional, off by default)
        -progress            <boolean>        Report progress 
        -help                <string list>    Display long help (empty list), or help for given parameters keys

BundleToPerfectSensor

Complete documentation: https://www.orfeo-toolbox.org/CookBook/Applications/app_BundleToPerfectSensor.html or -help

Parameters: 
MISSING -inp                     <string>         Input PAN Image  (mandatory)
MISSING -inxs                    <string>         Input XS Image  (mandatory)
MISSING -out                     <string> [pixel] Output image  [pixel=uint8/uint16/int16/uint32/int32/float/double/cint16/cint32/cfloat/cdouble] (default value is float) (mandatory)
        -elev                    <group>          Elevation management 
        -elev.dem                <string>         DEM directory  (optional, off by default)
        -elev.geoid              <string>         Geoid File  (optional, off by default)
        -elev.default            <float>          Default elevation  (mandatory, default value is 0)
        -mode                    <string>         Mode [default/phr] (mandatory, default value is default)
        -method                  <string>         Algorithm [rcs/lmvm/bayes] (mandatory, default value is rcs)
        -method.lmvm.radiusx     <int32>          X radius  (mandatory, default value is 3)
        -method.lmvm.radiusy     <int32>          Y radius  (mandatory, default value is 3)
        -method.bayes.lambda     <float>          Weight  (mandatory, default value is 0.9999)
        -method.bayes.s          <float>          S coefficient  (mandatory, default value is 1)
        -lms                     <float>          Spacing of the deformation field  (optional, off by default, default value is 4)
        -interpolator            <string>         Interpolation [bco/nn/linear] (mandatory, default value is bco)
        -interpolator.bco.radius <int32>          Radius for bicubic interpolation  (mandatory, default value is 2)
        -fv                      <float>          Fill Value  (optional, off by default, default value is 0)
        -ram                     <int32>          Available RAM (MB)  (optional, off by default, default value is 128)
        -inxml                   <string>         Load parameters from XML  (optional, off by default)
        -progress                <boolean>        Report progress 
        -help                    <string list>    Display long help (empty list), or help for given parameters keys

Can you be more specific? It seems that the 3 options Simple RCS, Local Mean and Variance Matching and Bayesian Fusion are available in the two applications!

Antoine,
You are right, the 3 options for Methods are present for both applications. Sorry for the noise.
Agus

I agree with the author of the topic. It is very strange to use a function called “BundleToPerfectSensor” to perform pan-sharpening. In addition, the input parameters in QGIS OTB plugin have different names than in the documentation:

1

1 Like