Repository: opencv
Issue: MultiBandBlender loss of fine details
Labels: feature,category: stitching

### System Information

OpenCV version: [4.x](https://github.com/opencv/opencv/tree/0323761ea685e03b106bd7612a10756c7fbd6ef9) ([build info](https://gist.github.com/krupkat/87a1b7550e8f376d9f837b275c0f6d01#file-opencv_build_info-md))
OS: Windows 11
Compiler: Visual Studio Community 2022 17.6.5 (cl.exe 19.36.32537)

### Detailed description

After calling [MultiBandBlender::blend](https://github.com/opencv/opencv/blob/0323761ea685e03b106bd7612a10756c7fbd6ef9/modules/stitching/include/opencv2/stitching/detail/blenders.hpp#L137) the result image loses fine detail. It seems that the algorithm drops the higher frequencies in the image somehow.

Example 100% crops:

Before blending               |  After blending
--------------------------|-------------------------
![crop_1_input](https://github.com/opencv/opencv/assets/6817216/5b16ff70-1987-4166-8a1f-3422f83827aa) | ![crop_1_after_blend](https://github.com/opencv/opencv/assets/6817216/495e472e-46cb-4053-b246-ce21e710e30b)
![crop_2_input](https://github.com/opencv/opencv/assets/6817216/6b17d525-40fa-420f-a0b9-8669cb430c24) | ![crop_2_after_blend](https://github.com/opencv/opencv/assets/6817216/fa6f35b9-976d-4503-a60c-aed81d544480)


### Steps to reproduce

Blend utility loads inputs that were snapshot just before blending (while running example_cpp_stitching included in OpenCV).

```cpp

#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"

#include "opencv2/stitching/detail/blenders.hpp"

using namespace cv;

void Blend(const std::vector<Point> &corners, const std::vector<Size> &sizes,
           const std::vector<UMat> &images, const std::vector<UMat> &masks)
{
  int num_bands = 5; // the default
  Ptr<detail::Blender> blender = makePtr<detail::MultiBandBlender>(false, num_bands);

  blender->prepare(corners, sizes);

  for (size_t idx = 0; idx < images.size(); idx++)
  {
    blender->feed(images[idx], masks[idx], corners[idx]);
  }

  UMat result;
  UMat result_mask;
  blender->blend(result, result_mask);

  imwrite("result_opencv.png", result);
}

// Only input reading
int main(int argc, char **argv)
{
  // Read corners (cv::Point) from argv[1]
  FileStorage read(argv[1], FileStorage::READ);
  std::vector<Point> corners;
  auto corners_node = read["corners"];
  for (auto it = corners_node.begin(); it != corners_node.end(); ++it)
  {
    Point p;
    *it >> p;
    corners.push_back(p);
  }

  // Read cv::Mat inputs from argv[2++], split them to image + mask + image size
  std::vector<UMat> images;
  std::vector<UMat> masks;
  std::vector<Size> sizes;

  for (size_t idx = 2; idx < argc; idx++)
  {
    Mat image = imread(argv[idx], IMREAD_UNCHANGED);
    std::vector<UMat> image_channels;
    split(image, image_channels);

    // Extract mask
    masks.push_back(image_channels[3]);

    // Extract input + convert to expected CV_16S format
    UMat image_without_mask;
    image_channels.pop_back();
    merge(image_channels, image_without_mask);

    UMat image_16s;
    image_without_mask.convertTo(image_16s, CV_16S); // same as in cv::Stitcher::composePanorama
    images.push_back(image_16s);

    sizes.push_back(image_16s.size());
  }

  Blend(corners, sizes, images, masks);
  return 0;
}
```

Input files: https://drive.google.com/drive/folders/1GRG0plQu69hEP7x81vEMo4qObBkZwgD8?usp=sharing
Run command:

```
./blend blender_inputs.yml img_0.png img_1.png
```

You can apply this [patch](https://gist.github.com/krupkat/87a1b7550e8f376d9f837b275c0f6d01) to OpenCV to snapshot your own inputs for the blend utility.

There are also the original jpegs in the drive folder and the result can be observed by running the example stitching program (result also uploaded in the drive):

```
./samples/cpp/example_cpp_stitching PXL_20220414_153659236.jpg PXL_20220414_153701725.MP.jpg
```

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)