# Stitching Misalignment (grid/collection)

Hello!

I am just now learning Fiji and have been struggling. I need to stitch together multiple images to create a cross-section of pine stems. I have the images in the correct order, snaking by row to the left and up. Looking at the images, I can tell exactly where each section goes, but when I put it into the grid/collection stitching it comes out with the bottom at the top and vice versa and the sides right on top of the middle. I’ve been messing with it for several hours now and don’t know how to fix it. Does anyone have any ideas where I might be messing up?

Thanks so much!

Dear katie_s,
Based off what you have described, there are a couple of things you can try. To start, based off the bottom and the top being flipped, it sounds like you might want to try and flip the direction that you are trying to stitch the images.
Can you post an example of the issue that you are having, as well as the correlation scores that you got?

Thanks so much for your help! I am trying to figure out how to upload an image onto this forum, but it keeps giving me an error. Until then, here is the correlation results that I get.

CORRELATION
p6_pi15b_x10_st15.tif[1] <- p6_pi15b_x10_st14.tif[1]: (1031.0, -23.0) correlation ®=0.08821657 (560 ms)
p6_pi15b_x10_st15.tif[1] <- p6_pi15b_x10_st10.tif[1]: (-77.0, 963.0) correlation ®=0.0933349 (273 ms)
p6_pi15b_x10_st15.tif[1] <- p6_pi15b_x10_st11.tif[1]: (907.0, 863.0) correlation ®=0.07071169 (30 ms)
p6_pi15b_x10_st14.tif[1] <- p6_pi15b_x10_st13.tif[1]: (1110.0, 184.0) correlation ®=0.3991474 (118 ms)
p6_pi15b_x10_st14.tif[1] <- p6_pi15b_x10_st10.tif[1]: (-1328.0, 1028.0) correlation ®=0.061513636 (35 ms)
p6_pi15b_x10_st14.tif[1] <- p6_pi15b_x10_st11.tif[1]: (-96.0, 986.0) correlation ®=0.096035525 (125 ms)
p6_pi15b_x10_st14.tif[1] <- p6_pi15b_x10_st12.tif[1]: (1037.0, 675.0) correlation ®=0.03006902 (27 ms)
p6_pi15b_x10_st13.tif[1] <- p6_pi15b_x10_st11.tif[1]: (-1026.0, 816.0) correlation ®=0.031446543 (28 ms)
p6_pi15b_x10_st13.tif[1] <- p6_pi15b_x10_st12.tif[1]: (-1332.0, 1030.0) correlation ®=0.20740664 (97 ms)
p6_pi15b_x10_st10.tif[1] <- p6_pi15b_x10_st11.tif[1]: (922.0, -1034.0) correlation ®=0.4345005 (80 ms)
p6_pi15b_x10_st10.tif[1] <- p6_pi15b_x10_st9.tif[1]: (-6.0, 866.0) correlation ®=0.41811287 (93 ms)
p6_pi15b_x10_st10.tif[1] <- p6_pi15b_x10_st8.tif[1]: (1007.0, 649.0) correlation ®=0.13315704 (17 ms)
p6_pi15b_x10_st11.tif[1] <- p6_pi15b_x10_st12.tif[1]: (853.0, 3.0) correlation ®=0.15345049 (77 ms)
p6_pi15b_x10_st11.tif[1] <- p6_pi15b_x10_st9.tif[1]: (-1110.0, 800.0) correlation ®=0.15376706 (19 ms)
p6_pi15b_x10_st11.tif[1] <- p6_pi15b_x10_st8.tif[1]: (246.0, 790.0) correlation ®=0.04134942 (103 ms)
p6_pi15b_x10_st11.tif[1] <- p6_pi15b_x10_st7.tif[1]: (1382.0, 1020.0) correlation ®=0.18175186 (19 ms)
p6_pi15b_x10_st12.tif[1] <- p6_pi15b_x10_st8.tif[1]: (-878.0, 696.0) correlation ®=0.1018041 (21 ms)
p6_pi15b_x10_st12.tif[1] <- p6_pi15b_x10_st7.tif[1]: (542.0, 986.0) correlation ®=0.1914409 (68 ms)
p6_pi15b_x10_st9.tif[1] <- p6_pi15b_x10_st8.tif[1]: (1300.0, -78.0) correlation ®=0.4441999 (85 ms)
p6_pi15b_x10_st9.tif[1] <- p6_pi15b_x10_st4.tif[1]: (-418.0, 936.0) correlation ®=0.5193204 (74 ms)
p6_pi15b_x10_st9.tif[1] <- p6_pi15b_x10_st5.tif[1]: (909.0, 844.0) correlation ®=0.09766106 (21 ms)
p6_pi15b_x10_st8.tif[1] <- p6_pi15b_x10_st7.tif[1]: (1110.0, -68.0) correlation ®=0.73740774 (91 ms)
p6_pi15b_x10_st8.tif[1] <- p6_pi15b_x10_st4.tif[1]: (-1311.0, 1014.0) correlation ®=0.12540103 (26 ms)
p6_pi15b_x10_st8.tif[1] <- p6_pi15b_x10_st5.tif[1]: (700.0, 802.0) correlation ®=0.19379422 (74 ms)
p6_pi15b_x10_st8.tif[1] <- p6_pi15b_x10_st6.tif[1]: (859.0, 859.0) correlation ®=0.42082927 (22 ms)
p6_pi15b_x10_st7.tif[1] <- p6_pi15b_x10_st5.tif[1]: (-892.0, 844.0) correlation ®=0.08808579 (20 ms)
p6_pi15b_x10_st7.tif[1] <- p6_pi15b_x10_st6.tif[1]: (-251.0, 929.0) correlation ®=0.8159782 (84 ms)
p6_pi15b_x10_st4.tif[1] <- p6_pi15b_x10_st5.tif[1]: (1244.0, -74.0) correlation ®=0.5277686 (83 ms)
p6_pi15b_x10_st4.tif[1] <- p6_pi15b_x10_st3.tif[1]: (691.0, 791.0) correlation ®=0.6554751 (90 ms)
p6_pi15b_x10_st4.tif[1] <- p6_pi15b_x10_st2.tif[1]: (1314.0, 998.0) correlation ®=0.12402498 (22 ms)
p6_pi15b_x10_st5.tif[1] <- p6_pi15b_x10_st6.tif[1]: (1334.0, -80.0) correlation ®=0.40151075 (90 ms)
p6_pi15b_x10_st5.tif[1] <- p6_pi15b_x10_st3.tif[1]: (-874.0, 1006.0) correlation ®=0.120340884 (21 ms)
p6_pi15b_x10_st5.tif[1] <- p6_pi15b_x10_st2.tif[1]: (426.0, 812.0) correlation ®=0.86204946 (78 ms)
p6_pi15b_x10_st5.tif[1] <- p6_pi15b_x10_st1.tif[1]: (1207.0, 763.0) correlation ®=0.43758038 (21 ms)
p6_pi15b_x10_st6.tif[1] <- p6_pi15b_x10_st2.tif[1]: (-906.0, 890.0) correlation ®=0.59181625 (18 ms)
p6_pi15b_x10_st6.tif[1] <- p6_pi15b_x10_st1.tif[1]: (-124.0, 844.0) correlation ®=0.86229426 (81 ms)
p6_pi15b_x10_st3.tif[1] <- p6_pi15b_x10_st2.tif[1]: (978.0, -58.0) correlation ®=0.6183272 (74 ms)
p6_pi15b_x10_st2.tif[1] <- p6_pi15b_x10_st1.tif[1]: (1110.0, -264.0) correlation ®=0.13821313 (87 ms)

2 Likes
2 Likes

Dear katie_s
Can you also include a picture of the stitching settings that pop up after you set the direction of the stitching?
Based off the sample image that you included, their may be a couple of changes you could make to improve the stitching. It looks likes your `regression threshold` might be set to high. This is the value used to determine if two images are overlapping. Try reducing it to 0.1 and see if that improves the stitching.
Also, here is a link to an overview of Imagej Stitching. You might find some of the information on the site helpful in understanding how the stitching plugin functions.

I tried it with the regression threshold reduced and it definitely looks better.
My images are not a perfect grid - i.e. some rows have four tiles while others only have three - could that be what is causing the problem?
And thank you for the link! I have read that page, but I will go back and look through it again.

1 Like

Dear katie_s
If you are not working with a perfect grid then that will cause some issues. You will not be able to use the grid stitching. Instead, you will need to change stitching type to either `filename defined position` or `unknown position`.
I would recommend the `filename defined position` option. With this option, you create a .txt file which has the approximate coordinates of the stacks. Here is an example file:
Example file.txt (216 Bytes)

To briefly explain, the `filename defined position` option will allow you specify the approximate xyz coordinates of the upper left corner of the stack. What you need to do is edit the example text to include all of the files you want to stitch along with their approximate coordinates in the final stitch. The stitching plugin will then try and align the stacks based off the coordinates.
In Imagej, the image coordinate system starts from the upper left corner of an image and both x and y increase positively as you move towards the bottom right corner of the image. So you will need to define all of the stacks that you want stitched in the file, along with their approximate coordinates. You will also need to save the coordinate file to the folder which contains the images.
If you look at the sample that I provided, I assumed that the input stacks are 200 pixels tall in the y direction and that the second image should be orientated directly under the first image. So the offset from the first image to the second is (0,200,0).

Thanks! I played around with the filename defined position and still couldn’t get it to work. In the end, I just used pairwise stitching and found that there were gaps between a couple of the tiles that were throwing them off. Hopefully if I correct that in the future, and have an even number of tiles per row, the snake by rows function will end up working.

Thank you so much for your help! I really appreciate it!

1 Like