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

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?

why ? please explain

well, that needs some overlap (and as you found out, from the same image)

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

show your data please

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.

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

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

is that the actual job ? defect detection on rolls ?

Yes, This is the actual job.