# How to efficiently concat multiple images and overlap the duplicates part of the images

**URL:** <https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299>\
**Category:** Python\
**Tags:** imgproc\
**Created:** [August 20, 2023, 11:51am UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299 "2023-08-20T11:51:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vikas_gupta/32/8563_2.png) [@Vikas\_Gupta](https://forum.opencv.org/u/Vikas_Gupta)\
**Post date:** [August 20, 2023, 11:51am UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/1 "2023-08-20T11:51:22Z")

</div>

Hey team, I have around 40 images and need to concat them into 1 and in order.  
the possible aspect ratio can be 4x5 or 5x4 based on how many images will be in rows and how many in columns.

I tried using hconcat and vconcat but that needs some overlapping on the image edges.

I also tried image stitching but 2 images can be similar but not of same object so stitching is assuming them to be same and not working properly.

I am assuming I need some solution where I am applying stitching after the concat just to remove duplicates.

can anyone help me to how can I achieve it?

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [August 20, 2023, 12:28pm UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/2 "2023-08-20T12:28:26Z")

</div>

> [@Vikas\_Gupta](#):
>
> I tried using hconcat and vconcat but that needs some overlapping on the image edges.

why ? please explain

> [@Vikas\_Gupta](#):
>
> I also tried image stitching

well, _that_ needs some overlap (and as you found out, from the _same_ image)

> [@Vikas\_Gupta](#):
>
> where I am applying stitching after the concat just to remove duplicates.

you probably want to filter your _part_ images before for duplicates (using phash or similar) . stitching cannot do this

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [August 20, 2023, 1:08pm UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/3 "2023-08-20T13:08:18Z")

</div>

show your data please

---

<div class="post-metadata">

**Author:** ![Vikas\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vikas_gupta/32/8563_2.png) [@Vikas\_Gupta](https://forum.opencv.org/u/Vikas_Gupta)\
**Post date:** [August 20, 2023, 2:27pm UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/4 "2023-08-20T14:27:49Z")

</div>

[https://www.sendgb.com/upload/?utm\_source=2ym6pvqa7lY](https://www.sendgb.com/upload/?utm_source=2ym6pvqa7lY)

there are 2 sample data on it.  
This is basically what I wanted to try

“”"  
My product is a roll.

I have a camera that takes photos of my product.

I take about 40 or 50 photos to complete the overview.

i need to merge them firstly and compare with the tiff file of my roll.

and detect some defects on it

i need to see differences like in a diff

but the most important thing, i don’t have 2 photos to compare

i have 1 TIFF file and 40-50 or 60 small photos that will be same as tiff file when connected  
“”"

In the sample there are 2 folders  
“230816\_14/230816\_14” and  
“230816\_13/230816\_13”

Where each folder contains 20 pictures  
There are tiff files for both of these samples  
“23.08.16\_13.jpg” and “23.08.16\_14.tif”  
File extension doesn’t matter here.

Now I am confused on how to proceed with it.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [August 20, 2023, 3:17pm UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/5 "2023-08-20T15:17:40Z")

</div>

your “sendgb” link doesn’t actually link to anything.

---

<div class="post-metadata">

**Author:** ![Vikas\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vikas_gupta/32/8563_2.png) [@Vikas\_Gupta](https://forum.opencv.org/u/Vikas_Gupta)\
**Post date:** [August 20, 2023, 3:20pm UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/6 "2023-08-20T15:20:14Z")

</div>

> **[Desktop.zip](https://drive.google.com/file/d/14HZ1U0XwPeaDAuShQzO2X1JiujgMwHuy/view?usp=sharing)**
>
> Google Drive file.

sorry for the issue with the link, You may try this.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [August 21, 2023, 5:44am UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/7 "2023-08-21T05:44:16Z")

</div>

> [@Vikas\_Gupta](#):
>
> compare with the tiff file of my roll.
> 
> and detect some defects on it

is _that_ the actual job ? **defect detection** on rolls ?

---

<div class="post-metadata">

**Author:** ![Vikas\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vikas_gupta/32/8563_2.png) [@Vikas\_Gupta](https://forum.opencv.org/u/Vikas_Gupta)\
**Post date:** [August 21, 2023, 9:01am UTC](https://forum.opencv.org/t/how-to-efficiently-concat-multiple-images-and-overlap-the-duplicates-part-of-the-images/14299/8 "2023-08-21T09:01:46Z")

</div>

Yes, This is the actual job.
