Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

neocell

macrumors 65816
Original poster
May 23, 2005
1,073
2
Great White North
Hi, I hope someone here can help me with this. Here's the scoop. I have a bunch of images that are separated into red, green and blue and I need to merge them back into one (from 3 to 1, 1 red, 1 green, 1 blue into 1 pretty RGB image). So I have hundreds of merged images to make. Right now I have all the files named red1, red2, red3..., green1, green2..., blue1, blue2... etc. I'm using software running on Window's 2000 to do the merging though I was hoping that someone could tell me how I can automate this on my Mac so I don't have sit there clicking which file to open again and again and again. I was hoping that I could use automator and photoshop so that I can just run one script and have it search a specific folder and then merge all the appropriate red, green and blue files (folders have anywhere from 150, to 450 images) without any user input, and then save the merged files with an appropriately named title (ie. merged 1 up to merged x in folder whatever). Please let me know if this is possible. Thanks a lot

Don't know if this is the right forum. Mods please move it to most appropriate one. Thanks
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
neocell said:
Please let me know if this is possible.
I don't know of any Automator or Photoshop actions that will do this, but just out of curiosity, what format are your original images in, and what format are you trying to get the merged images into (.tif, etc.)? Is each of the single-color originals a single-plane grayscale image?
 

Mr. Anderson

Moderator emeritus
Nov 1, 2001
22,568
7
VA
Depending on the format, it almost sounds like you'd need to create an app specifically to do what you want. I remember way back in the day working with some satellite imagery and having to do the same thing - but I was working on a Sun Workstation and wrote a small program in C to read in the files and output the combined image.

D
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Mr. Anderson said:
Depending on the format, it almost sounds like you'd need to create an app specifically to do what you want. I remember way back in the day working with some satellite imagery and having to do the same thing - but I was working on a Sun Workstation and wrote a small program in C to read in the files and output the combined image.

D
That's what I'm thinking. It looks way too specific for any currently existing program to do.
 

lexfuzo

macrumors 6502
Mar 15, 2005
262
0
The heart of Europe
kainjow said:
That's what I'm thinking. It looks way too specific for any currently existing program to do.

nonono, ImageMagick does the trick!
Grab your copy from http://www.imagemagick.org/ and issue the following command (one line):

convert red1.tif green1.tif blue1.tif -channel RGB -combine combined.tif

(works with almost any other format as well, not just .tif.)
Wrap some shell script around it to batch process your files.
 

neocell

macrumors 65816
Original poster
May 23, 2005
1,073
2
Great White North
Thanks a lot, every one for getting back. They're all tiff files and I have no idea if they're single plane gray scale. They're fluorescent images, thus the one red, one green, one blue and as I said I need to merge them (preferably to a tiff) to get the final image. I'm currently using an image analysis system to do this, but it's quite long and tedious and was hoping for the automatic batch processing option. I was afraid that it maybe to specific for the current offerings of Automator. I'll take a look at what lexfuzo has suggested but quite honestly I have no idea how to write shell scripts. Thanks a lot for all the help
 

lexfuzo

macrumors 6502
Mar 15, 2005
262
0
The heart of Europe
neocell said:
I'll take a look at what lexfuzo has suggested but quite honestly I have no idea how to write shell scripts.

Don't be afraid ;). A shell script is just a plain text file containing all the commands you want to use, one after the other (or in some loop structure)

So, let's say
convert red1.tif green1.tif blue1.tif -channel RGB -combine combined.tif
does what you need and the other files are named red2, green2 and so on.
then you could put all commands in one text file:
convert red1.tif green1.tif blue1.tif -channel RGB -combine combined1.tif
convert red2.tif green2.tif blue2.tif -channel RGB -combine combined2.tif
...
These strings you even can create with Excel or the like (CONCATENATE, ...)

Or you put it in a loop:
i=0
while [ $i -lt 1000 ]
do
convert red${i}.tif green$${i}.tif blue${i}.tif -channel RGB \
-combine combined${i}.tif
i=`expr $i + 1`
done

... or similar.
It's easier than you might expect and there are hundreds of tutorials on the web, for example this one:

http://www.tldp.org/LDP/abs/html/

Good luck :)
 

neocell

macrumors 65816
Original poster
May 23, 2005
1,073
2
Great White North
lexfuzo said:
Don't be afraid ;). A shell script is just a plain text file containing all the commands you want to use, one after the other (or in some loop structure)

So, let's say
convert red1.tif green1.tif blue1.tif -channel RGB -combine combined.tif
does what you need and the other files are named red2, green2 and so on.
then you could put all commands in one text file:
convert red1.tif green1.tif blue1.tif -channel RGB -combine combined1.tif
convert red2.tif green2.tif blue2.tif -channel RGB -combine combined2.tif
...
These strings you even can create with Excel or the like (CONCATENATE, ...)

Or you put it in a loop:
i=0
while [ $i -lt 1000 ]
do
convert red${i}.tif green$${i}.tif blue${i}.tif -channel RGB \
-combine combined${i}.tif
i=`expr $i + 1`
done

... or similar.
It's easier than you might expect and there are hundreds of tutorials on the web, for example this one:

http://www.tldp.org/LDP/abs/html/

Good luck :)

Thanks a lot. You guys have been great
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.