0

I have 2 images and when I stitch them, there'll be some black area in the resulting image. I'll share the images. so how can I stitch them without the black area?

I have a homography matrix and I stitch them using ROI.

But I have a search about "seamless clone" in OpenCV, but I don't yet know it'll help me. I need advice.

I want like that: enter image description here

https://www.harrisgeospatial.com/docs/html/images/Mosaic/DiagramUpdateFootprints.png

hede
  • 1
  • 2
  • dont overwrite during after warping but write to a separate image and merge afterwards, e.g. by not copying black pixels – Micka Sep 17 '19 at 09:24
  • @Micka I didn't get. I have these images. how do I merge them without black pixels? – hede Sep 17 '19 at 11:11
  • have a look at: https://stackoverflow.com/questions/22315904/blending-does-not-remove-seams-in-opencv/22324790#22324790 – Micka Sep 17 '19 at 12:22
  • @Micka of course, I hope it's useful – hede Sep 17 '19 at 12:43

1 Answers1

0

If you dont need a blending:

pseudo code:

inputs: image A, image B, backgroundColorRange X
outputs: image O

for each pixel in the output image:
    if(pixel(A) == X AND pixel(B) == X) pixel(O) = X;
    else if (pixel(A != X) AND pixel(B == X) pixel(O) = pixel(A);
    else if (pixel(A == X) AND pixel(B == X) pixel(O) = pixel(B);
    else if (pixel(A != X) AND pixel(B != X) pixel(O) = 0.5*pixel(A) + 0.5*pixel(B)
Micka
  • 19,585
  • 4
  • 56
  • 74
  • this is not a solution. It's working really slow. and you should give me a better solution :) – hede Sep 17 '19 at 12:42
  • create masks and use opencv's .setTo, .copyTo and .addWeighted functions to operate on the 4 different individual mask regions. The idea stays the same. – Micka Sep 17 '19 at 13:05
  • what about blend::seamlessBlend(first, second, mask, result); – hede Sep 17 '19 at 13:46