HELP Please! Need to Create Thousands of RGB Merges

Discussion in 'Mac Programming' started by neocell, Nov 24, 2005.

  1. macrumors 65816

    neocell

    Joined:
    May 23, 2005
    Location:
    Great White North
    #1
    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
     
  2. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    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?
     
  3. Moderator emeritus

    Mr. Anderson

    Joined:
    Nov 1, 2001
    Location:
    VA
    #3
    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
     
  4. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    That's what I'm thinking. It looks way too specific for any currently existing program to do.
     
  5. macrumors 6502

    Joined:
    Mar 15, 2005
    Location:
    The heart of Europe
    #5
    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.
     
  6. thread starter macrumors 65816

    neocell

    Joined:
    May 23, 2005
    Location:
    Great White North
    #6
    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
     
  7. macrumors 6502

    Joined:
    Mar 15, 2005
    Location:
    The heart of Europe
    #7
    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 :)
     
  8. thread starter macrumors 65816

    neocell

    Joined:
    May 23, 2005
    Location:
    Great White North
    #8
    Thanks a lot. You guys have been great
     

Share This Page