How can i stitch different image to form one image and remove the error?

Hello everyone,

I captured some images from of the one piece and i wanted to make a single image by stitching all images together. However, in the image stitching i am facing issues like

1)Previous Image strips does not match with next image strips, You can see the issue in image named as “Whole Picture issue”. Can you guys tell me how to solve this error?

2)After removing the error, whole image in actual should be like this , you can see error free image named as “Whole Picture actual”

3)Name of the each image, You can see actual image named as “Whole Picture naming”

4)All separate images, You can see folder named as “Each pictures” to do perform stitching.

Can you guys tell me a code to remove this error and stitch all the images ?Each pictures.zip (40.1 KB)

. Thanks a ton.

Dakota

Have you tried the Grid/Stitching plugin in Fiji? I find that super useful even when stuff is slightly offset and it’s pretty flexible on the input types.

I tried but still error is present in the problem. Can you explain further to remove the problem. Thanks a ton.

I tried but still error is present in the problem. Can you explain further to remove the problem. Thanks a ton.

Hi Dakota,

There appear to be a couple of issues that might make the raw data challenging to align, including that the individual files do not have completely uniform heights and that there is an approximately 2 pixel shift between each column based on the alignment of the red lines (at least in the first row images).

For example, the following Jython code (run on your row 1 images):

from ij import IJ, ImagePlus
from ij.process import ImageProcessor

#@ File[] (label="Select images", style="file") myImages

myImagePaths = [str(i) for i in myImages]
imps = [IJ.openImage(i) for i in myImagePaths]

#heights of your images do not match
#some are 100 and some are 101
#is this the source of the problem?
w, h = sum([imp.getWidth() for imp in imps]), max([imp.getHeight() for imp in imps])


impBitDepths = imps[0].getBitDepth()
print(impBitDepths)
stitchedImage = IJ.createImage("stitchedImage", w, h, 1, impBitDepths)

xCounter, yCounter = 0, 0
stitchip = stitchedImage.getProcessor()

for i, imp in enumerate(imps):
	width, height = imp.getWidth(), imp.getHeight()
	print(imp.getTitle(), width, height)
	imp.copy()
	ip = imp.getProcessor()
	stitchip.insert(ip, xCounter, yCounter)
	xCounter += width
	yCounter += 2

stitchedImage.show()

produces

whereas commenting out the yCounter incrementer in line 29 produces


which looks remarkably similar to your original stitched image.

Hope this helps!

2 Likes

Which software i need to use to run this code ?

One way is to:

  1. Open the Fiji macro editor (plugins > new > macro)
  2. paste the text into the window that opens
  3. change the language to python (language > python).

The code won’t solve the issues that appear to be in the raw data i.e. it wont reconstruct your “whole picture actual”. If you want the stitching to perfectly align the red horizontal bars you can threshold the image and try alignment based on the y index of the first bar in each picture or you can manually determine the y offset of each image and modify my code to account for that by changing the yCounter to a list of the relevant offsets.

1 Like

@meemrich Thanks a ton, It works but it removes the error in one pattern only. (Strips are not straight throughout the image). You can see actual image, it should be similar like that one. Probably error contains the “Pincushion” or “Barrel” error. Is it possible to change your code to adapt according to this error?

Also this code stitch all the image in row 1 only , can you add the feature to include 2nd row as well.

Thanks a lot

@meemrich Thanks a ton, It works but it removes the error in one pattern only. (Strips are not straight throughout the image). You can see actual image, it should be similar like that one. Probably error contains the “Pincushion” or “Barrel” error. Is it possible to change your code to adapt according to this error?

Also this code stitch all the image in row 1 only , can you add the feature to include 2nd row as well.

Thanks a lot

can you explain how should i try? Thanks a ton.