Jump to content
Welcome to InsanelyMac Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Photoshop - combine red and green channel images into a merged image?

4 posts in this topic

Recommended Posts

I am a developmental biologist carrying out experiments on a type of microscope known as a Confocal Laser Scanning Microscope (CSLM). Basically, this is a microscope coupled to some lasers which allow fluorescently-labelled parts of a biological sample to be imaged in high detail.


For each sample there will be a set of two images produced, named and numbered as follows:





Each image represents one fluorescent wavelength and correspond to green ( g ) and red ( r ). These images are in rgb colour.


I want to produce a merge of these two channels to generate a new TIFF file such that:


Green channel is taken from sample01_g.tif

Red channel is taken from sample01_r.tif


Which would show me how the different channels co-localise, or not.


This is fine to do by hand in Photoshop, but takes a long time when you have a couple of hundred images to process. So, what I would like to do is write a script that batch automates the process, like a droplet. I have the process outlined below:


1. Create a new RGB TIFF called sample01_merge.tif

2. Take the green channel from sample01_g.tif and copy it to the green channel of sample01_merge.tif

3. Take the red channel from sample01_r.tif and copy it to the red channel of sample01_merge.tif

4. Save sample01_merge.tif into a folder named "Merged Images" on the desktop

5. Close the opened images

6. Go to next set of images –> sample02_g.tif and sample02_r.tif

7. Create a new RGB TIFF called sample02_merge.tif....and go through step 2-6, untill the last set of images has been processed.


I have never used Applescript before and would love to learn, but I am making slow progress and would like to have this problem solved sooner than I will be able to do so by myself. So... I was wondering if anyone could give me some advice on how to go about doing this?


Any help will be greatly appreciated!


Best regards,


Share this post

Link to post
Share on other sites

Hi, it sounds interesting. Which kinds of samples are you analyzing?


I'm not really familiar with AppleScript and I would recommend you to consider creating a shell script utilizing the freeware tool Imagemagick (section "Combining RGB Channel Images").


This shell script should do the conversion:


dirMerged="Merged Images"

mkdir "$dirMerged"
# Separate red channel for images with suffix _r. Output in folder $dirMerged.
for img in *_r.tif; do
 convert "$img" -channel R -separate "$dirMerged"/"$img"
# Separate green channel for images with suffix _g. Output in folder $dirMerged.
for img in *_g.tif; do
 convert "$img" -channel G -separate "$dirMerged"/"$img"
# Combine red and green channels. Output in $dirMerged.
# Remove single channel images from $dirMerged.
cd "$dirMerged"
for img in *_r.tif; do
 convert "$img"_r.tif "$img"_g.tif -channel red,green -combine "${img}${suffixMerged}".tif
 rm "$img"_r.tif "$img"_g.tif

Share this post

Link to post
Share on other sites

It is cell samples from the retina of rats.


Thanks for your suggestion. I'm not familiar with imagemagick but I'll sure have a look at it now.

Share this post

Link to post
Share on other sites

I forgot to mention a thing. Imagemagick requires an additional installation argument for TIFF support.


I would recommend you to use homebrew to manage the installation.

After you set it up, enter "brew install imagemagick --with-libtiff" to set up imagemagick.

That should be all.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.