Create border when combining stacks/images & labeling each images with colored texts


I’m making a combined stacks of confocal images. I first made montage of green & red channel and combined that horizontally with composite of the same image. All of that is also combined with another identically processed confocal image.

I want to have white borders at all the image intersections. Right now I was only able to set border=12 when I used Make Montage function.

Also is there anyway to label each piece of this montage accordingly? I’d like to label green and red channel images with their corresponding protein names, and the composite as “Merged”.

Here is an example of how my image looks right now.


	getDimensions(w, h, channels, slices, frames);
	for (j = 0; j < channels; j++) { // sets contrast
		run("Enhance Contrast", "saturated=0.05");

	run("Make Substack...", "channels=1,3"); // gets rid of DAPI
	run("Make Montage...", "columns=1 rows=2 scale=.5 border=12"); // green + red montage
	dotIndex = indexOf(image_name, "."); // close green + red montage
	image_sub = substring(image_name, 0, dotIndex);
	image_name2 = image_sub+ "-1.tif";
	selectImage(image_name); // create the right hand side
	run("Stack to RGB");
	run("Combine...", "stack1=Montage border=12 stack2=["+image_name+" (RGB)]"); // individual image montage

Thank you for your help!

Hi @CeC,

You could do it “by hand” with makeText and makeLine.


Hi @VirtualSlide,

Thank you for your reply! I’m a bit lost as to how to use makeLine. I was thinking about using getDimensions's w & h for makeLine(0,0,w,h) but the overlays seem to disappear once I combine/montage separate images.

Do you have any ideas? It’d be great if you could help out.

Hi @CeC,

I would do the drawing of line after the montage.
Remember that makeline creates a selection. So you have to fill it after with white. You can also specify the with of line in makeline.

will draw a selection line in the diagonal of the image.


Hi @VirtualSlide,

Thanks for the reply.

I have 8 images with 3 channels (red, green, blue). It looks like this (time 2 vertically):

The red and green channels are vertically stacked first, then combined horizontally with composite of all 3 channels. These representative of individual images are then combined to make the final big montage.

What should I do to get the coordinates of all the corresponding x & y points so that all of individual images, including the green and red channels only, have white border? I have a lot of images to process, so it’s important for me to come up with a semi-automated system.

Thank you so much for your reply! It’s really helpful since I really don’t have anyone in the department to ask questions.

Hi @CeC,

I think it is just a matter of math.
Wih * getDimension*, you’ll have the size of your image (let’s say w and h).
You know that the white border is 2pixels on left and 3px on top. The red and green components are half size (w/2 and h/2).
So your lines have to be for 1st red component


and so on for other ones


Hi @VirtualSlide,

Thank you for showing floor(). I didn’t know it existed. Is there any reason why you add 2 pixel for x and 3 pixel for y?

It seems that these white lines are going to mask some parts of the images. I wonder if this can be avoided.

Unfortunately, this ROI information disappears when I combine separately saved images. Is there anyway to combine ROI overlay when I run("Combine...") them?

Thank you again for your help!

Hi @CeC,

I used 2 and 3 pixels because on your example image, borders were 2 and 3 pixels.
If you chose a 2 pixel line, every image will lose 1 pixel at the edges. If you want to avoid it, you have to write your own montage macro.
Have you tried to draw your overlay (in the Edit menu)?