Stitching images

Hi all. Have anyone figured out an easy way to stitch images acquired using stack and scan feature?

Thanks

I don’t think there is a native openflexure stitcher. A couple of mentions of successful stitching on the forum here and here .

Thanks William. I saw those posts before. I was able to stitch using ImageJ using a simple script that I made. However, the biggest problem I have is that the file names generated by open flexure software are confusing. It saves the images as using the X, Y, Z coordinates I think. It will be much easier having a sequential file name system or something like that.

Hi
I’ve been looking at ways to stitch images and I’ve found (but not tried for now) these:

1 Like

I just started using Microsoft’s Image Composite Editor like you described above. The part for me that was hard to understand was setting up the Stack and Scan and what direction it would go? How many steps to configure it for overlap of the images at say a 50% overlap? I find that “Snake” makes the most sense to me because it starts in the lower right corner and works its way up first on the Y, then left on X and back down, etc as it snakes across the stage.

So, to scan the whole stage where my max on X and Y is 50000 I can do this…

I watch the debug output now in an SSH window and it appears scanning the whole stage took 973 seconds, so 16 minutes.

With my steps at 10 on x and y, that’s 10x10, so it will create 100 images. I resized the images to 640x480, so the disk usage for that is 17MB.

I download the gallery collection.

Then I open the folder in Microsoft’s ICE (Image Composite Editor) and just use all of the automatic settings.

After stitching my image seems screwed up, so I’m guessing 5000 was too large of a step as the stitcher wasn’t able to guess at the correct position of each image. It’s like I ended up with almost no overlap.

So I went back and used the “Structured Panorama” approach. Here’s the settings I used to force it to the “snake” pattern that the microscope used to grab the images. What I don’t get is that Zigzag seems to give me a better preview here than Serpentine, even though I would presume Serpentine in Microsoft’s app matches “Snake” in the microscope app.

The final stitched image looks pretty good, although I have some blurry spots where I think the app had to guess. So that bothers me.

I went back and chose Serpentine.

And here’s the result. I’m still confused as I would think this would be the correct setting, but it doesn’t appear to be.

In conclusion, the best result for me despite some of the blurriness is

2 Likes

That is a good stitch on a very challenging image. There is a lot if blank area that does not give the algorithm very much to go on to match up where it should be joined together. Something with detail all across the slide will work much better.

I tried to run the stitching again with steps at 2500 to get more overlap. To scan the whole stage requires 20x20 steps then, so 400 images instead of 100 images, which takes MUCH longer to run.

Whew! That took 2776 seconds or 46 minutes. It was about 106MB for the images.

I tried using all of the automatic settings.

And it worked great but it did take about 45 minutes for the stitching to complete.

2 Likes

Hello! If you want to upload your images for me to download somewhere I can give it a go using my method and report back to you. Then if it’s successful I can detail the steps for you.

I’ve found ImageJs stitching tools to be much better once you get the parameters right.

N.B - to combat your problem of the image sequence labelling, you can import the images from your folder (sorted by date) into a stack in Imagej, then export the image sequence with sequential filename numbering.

2 Likes

Thanks so much nonacastro for the links. I was not aware of the MIST software. I will try it and report back.
Gracias por tu ayuda!

1 Like

Thanks John! I really appreciate you took the time to comment on my post. I went through the same hoops and loops to get a stitched image. However, I used ImageJ which gave me better results and can support stacked images as well.

Like William said, I found that large blank areas are not ideal for stitching. I solve this using a marker to fill the gaps and then delete with photoshop.

I did successfully completed some stitching but it is very laborious to get it done. I am planning to scan HUNDREDS of slides for teaching and research purposes. Hence, trying to develop a “drag and drop” solution.

So this is what I did and what worked best for me so far:

  1. scan and stack “Snake” mode. In this example I did a 5x5 grid with 3 image stack for a total of 75 images.
  • Note: I will stop doing stack images and modify the imageJ code because I see no improvement in image quality whatsoever.
    Original file names. Note the identical time stamp in several images.
  1. Save files to USB drive and transfer to my Mac. Rename images sequentially as img1.jpeg t img75.jpeg
    Renamed images after transferring to my Mac
  1. However, as mentioned this is my biggest challenge. The files names are a little bit confusing to me. I cannot use the time stamp to organize them because many have the same time. Sometimes during transfer the files get reorganized and it is all jumbled up making stitching impossible to me.
  1. Run ImageJ script I coded to create a single focused image for each stack set.
  1. If I was able to rename the images sequentially then I run the following script in imageJ (fiji).

dir = getDirectory(“Choose image sequence folder”);
title = “Untitled”;
width=512; height=512;
Dialog.create(“New Image”);
Dialog.addString(“directory:”, dir);
//Dialog.addChoice(“Type:”, newArray(“8-bit”, “16-bit”, “32-bit”, “RGB”));
Dialog.addNumber(“X:”, 5);
Dialog.addNumber(“Y:”, 5);
Dialog.addNumber(“Z:”, 5);
//Dialog.addCheckbox(“Ramp”, true);
Dialog.show();
title = Dialog.getString();
X = Dialog.getNumber();
Y = Dialog.getNumber();;
Z = Dialog.getNumber();;;
//type = Dialog.getChoice();
//ramp = Dialog.getCheckbox();
//if (ramp==true) type = type + " ramp";
//newImage(title, type, width, height, 1);
print(X,Y,Z)
i=1
FS=1
{for (xx=1;xx<X+1;xx++)
{for (yy=1;yy<Y+1;yy++)
{
for (zz=1;zz<Z+1;zz++)
{
FN= “img”+i+".jpeg";
open(dir+FN);
print(“X:”,xx,“Y:”,yy,“Z:”,zz,“FN:”,FN);
i=i+1;
}
run(“Focus Search Bar”);
run(“Images to Stack”, “name=Stack title=[] use”);
run(“Stack Focuser “, “enter=5”);
selectWindow(“Focused_Stack”);
selectWindow(“Stack”);
selectWindow(“Focused_Stack”);
saveAs(“Tiff”, dir+“Focused_Stack”+FS+”.tif”);
print(“filename:”,FS);
FS=FS+1;
close();
selectWindow(“Stack”);
close();
}
}
}
run(“Grid/Collection stitching”, “type=[Grid: column-by-column] order=[Left & Down] grid_size_x=X grid_size_y=Y tile_overlap=30 first_file_index_i=1 directory=[dir] file_names=Focused_Stack{i}.tif output_textfile_name=TileConfiguration.txt fusion_method=[Linear Blending] regression_threshold=0.30 max/avg_displacement_threshold=2.50 absolute_displacement_threshold=3.50 compute_overlap computation_parameters=[Save memory (but be slower)] image_output=[Fuse and display]”);
saveAs(“Tiff”, dir+“Fused.tif”);

  1. The script will also stitch the images
    In theory this should work but I get very inconsistent results. I found out that for a reason unknown to me the files are not always arranged in a snake pattern starting from lower right. I have to play with the stitch settings on ImageJ a lot to get one picture right. I get the same fails as you do.

Here is a good one after playing with the settings

Once again. Thanks for the good vibes and camaraderie

Daniel

1 Like

I agree on ImageJ. I use it a lot and get good results.

As you can see in my post above, is hard to sort by date because many images have the same timestamp.

Another great opensource stitching software: