Handle whole slide images

I want to know which method is preferrably used to handle whole slide images without memory limitations .
Which is the best algorithm in ImageJ that can be used for slide image stitching.

For example i want to save a whole slide image of size greater than 500MB


Perhaps it’s worth taking a loot at the BigStitcher plugin? This should handle images of that size…

1 Like

Thanks for reply.

Which all are the algorithms in ImageJ for whole slide stitching.

And which is best algorithm.

I can only point you to these Stitching options in ImageJ/Fiji:

Which algorithms and how they are implemented should be documented/referenced in those pages… you can always look at the source code for them as well.

1 Like

I have tried to stich images using grid/collection plugin in fiji. But I am not getting desired output.
I have 16 images(4*4) with 20px overlap in both vertical and horizontal.Ref image net 20.zip (1.8 MB)

Hi @Shilpa0484,

The overlap you set should be based on how much overlap they were captured with. I looked for shared structures between adjacent tiles and estimated the overlap was actually 10% so tried that and I think the result looked pretty good (see below). Does this output seem okay?

1 Like

When I tried i didn’t get.
Can u tell me the steps you have done to get output.

I named files to be “Tileimage01.tiff” I chose stitching->grid collection stitching. Then I chose the appropriate scan direction, which I think in your case is scan by rows. Then in the options I pick the correct folder, change the file name style to be Tileimage{ii}.tif, reduce the overlap to 10% and then run the stitching.

But final result is blank.

In log its showing finished.
Is there any problem with software, any mistakes when i installed it.
Kindly help

Hi @Shilpa0484,

Sorry, I had forgotten that had happened. It’s to do with how grid collection deals with colour image. I’m not sure why it’s giving you the 4th channel but that’s the issue, you only need the first three channels (the red, green and blue). The 4th channel being removed fixes the display.

What I did was go to:
Image > Colour > Channel Tools…
Untick the 4th channel then went to Image > Type > RGB colour to convert back to RGB colour image.


1 Like

Thank you so much. It worked for colour images.
So what I have to do to stitch monochrome image.
I need 4*4 final stitched image.Overlap is 20px

can you please clearly indicate steps you have done

Trial.zip (215.7 KB)

I am not getting properly stitched

Hi @Shilpa0484,

Could I ask about the origin of these images and what you hope to do with them? The new images are incredibly low resolution and I find it very difficult to even see byeye where each tile should be despite the fact they have a large overlap.

Also, you say these are monochrome but they are actually RGB images like your first ones. This and the fact they are PNG format leads me to believe they did not come off the microscope. If you want the best stitching it would be better if you were using the raw data files.

I did try stitching these with a 30% as overlap setting (the tiles are 78 x 65 pixels so the overlap is 25-30% depending on dimension) and got the below image (once again the 4th channel needed removed).


Obviously, two parts of the image are in black where the stitching hasn’t managed so then I turned off the “Compute Overlap” setting to just how it places the 4x4 images. The result of that is below. Obviously that image doesn’t look great so I don’t know if perhaps there are missing tiles or an error with capturing or the naming of files but as I said the low resolution means it’s quite hard to work out by eye what’s going on which is why I’m asking their origin and the workflow you hope to continue on with them.



1 Like

I have programmed a macro to handle stitching of whole slide images.
I have to geeralize the program.
I have programmed in such a way that name of images to be stitched is in form Tileimage{i}.png.
Only png files can be input file format.

How can I generalize the program in such a way that user can input the name of file and its format.
Program.txt (9.7 KB)

Using a combination of the macro functions getDirectory(string), File.getParent, getFileList(directory), File.nameWithoutExtension,File.isDirectory indexOf and the substring functions you can ask the user for a directory (or file), get the location on disk as a path, get the filename, its extension and all you otherwise need to process files of a certain format.

See the FileDemo and BatchProcessFolder for examples.
By the way, the latter tests for a directory based on endsWith(), which better be replaced with File.isDirectory to avoid confusion between / and \ in path names.

A few general remarks:
Have a look at the DialogDemo to make your input more friendly.

In your rather large macro, you repeat yourself quite a few times with lengthly arguments. If you build your argument as a string, instead of all the repeats, you need only to call the stitching function once with the built argument; (notice: untested code, just the gist of it) e.g.

	gridArg= "snake by rows";
	orderArg="Right & Down";
	gridArg= "snake by rows";
	orderArg="Left & Up";
args =  "type=[Grid: " +
	 gridArg + "] order=[" + 
	 orderArg + "] grid_size_x="
	 +gx +" grid_size_y=" + gy + " tile_overlap=ol first_file_index_i=1 directory="
	 + dir 
	 + " file_names="
<....>	;//(here the rest of your arguments)
run("Grid/Collection stitching",args);
1 Like

Thanks:heart_eyes: you so much for suggestions

How to save final stitched image as JPG/stacked TIFF file?

have to develop a top level VI that allows the user to specify the file path, number of tiles, order of tiles and other relevant stitching algorithm parameters, output path and format, using front panel controls, which can perform image stitching based on these parameters by calling ImageJ from LabVIEW and save output as JPG/stacked TIFF file.

How can I call imageJ from Labview?

I have attached a macro program. When I tried to run that its showing error.new.zip (19.7 KB)

In that program, my aim is to display an image named ‘image.jpg’ in log.
I have saved file in images directory.

But its showing error.
Kindly help

In that program some lines are commented, I am trying to implement in that way