Otbcli_mosaic creates a gap in final mosaic

Context

I want to use otb_Mosaic to mosaic two geotiffs

Configuration setup

My system: macOS
Version of the OTB: 8.0
I installed the OTB with: the binaries

Description of my issue

I run the following command to mosaic two images

otbcli_Mosaic -il /data/img1.tif /data/img2.tif -out /data/merged.tif -comp.feather large -harmo.method band

The mosaic process works as expected except for one small detail. There is a small gap in between the two images as show below.

Could someone explain why this happens and how can it be fixed?

FWIW, I noticed gdal_merge did not have this issue but I can’t use it since it can’t harmonize colors like Orfeo does.

Hi,

Can you check the following:

  • Your images must overlap. If your images don’t overlap, then the color harmonization model cannot be computed properly
  • Is there any no-data value in your images? Check the value of your input images in the gap you mention. You can change the no-data value with ManageNodata application, and tell Mosaic the new value using the -nodata parameter.
  • Are your rasters in the same coordinate reference system?
  • Does the log mentions warnings? Can you show us the log?

The issue was, as you said, due to my images not overlapping. Does OTB have a utility to mosaic/merge images under these circumstances?

As you can see the images are right next to each other but don’t overlap.

If all your images don’t overlap, then the gdal_merge (or the otbcli_TileFusion, if your images are in row/cols) would be better suited.

You can also use otbcli_mosaic with an additional image overlapping all your images. You put this new image in the first position of the list. This way, the color harmonisation will work since there is a “bridge” between all images.

Tile Fusion seems like the way to go. How can we find if the images are in rows/cols? How can we find out what values to pass to -cols and -rows?

Using rasterio I was able to compute the shapes of the two images. They’re both (9905, 7637). Assuming -cols and -rows are the columns and rows for the final array (9905 * 2, 7637 * 2) , if I were to use otbcli_TileFusion would this usage be correct?

otbcli_TileFusion -il im1.tif im2.tif -cols 19810 -rows 15274 -out output.tif

Seems I’ll need to convert the image to a specific format since I’m getting this error:

(FATAL) TileFusion: itk::ERROR: ObjectList(0x6409d0): Impossible to GetNthElement with the index element 2; this element don't exist, the size of the list is 2.

No, you have to provide the number of rows and columns (see the documentation)

Oh the cols and rows indicate the position of the images in the final tile array. Got it.

So if I want to stack/merge/fuse two images horizontally then I should use the following command

otbcli_TileFusion -il im1.tif im2.tif -cols 2 -rows 1 -out output.tif