Merge Channels Macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Merge Channels Macro

heshamza
Hi Hi

I'm trying to create a merge channel macro where it automatically assigns a certain image for each merge color. Specifically, any image that ends with T1 I would like to have assigned to green, T2 for red, T3 for blue, and nothing for gray.

The problem is that whenever I run the macro (below), it says that I need a '(' in line 2... help??


run("Merge Channels...", "
red=[*None*]
green=[*None*]
blue=[*None*]
gray=[*None*]

for (i=1; i<=nImages; i++) {
        selectImage(i);
        title = getTitle;

        if (endsWith(title, "T1")) green=[title];
        else {
                if (endsWith(title, "T2")) red=[title];
                else {
                        if (endsWith(title, "T3")) gray=[title];
                        else {
                                if (endsWith(title, "T4")) gray=[title];
                                }
                        }
                }
}

create");
Reply | Threaded
Open this post in threaded view
|

Re: Merge Channels Macro

Gabriel Landini
On Friday 08 October 2010,  heshamza wrote:

> I'm trying to create a merge channel macro where it automatically assigns a
> certain image for each merge color. Specifically, any image that ends with
> T1 I would like to have assigned to green, T2 for red, T3 for blue, and
> nothing for gray.
>
> The problem is that whenever I run the macro (below), it says that I need a
> '(' in line 2... help??

I have not run this, so I do no know if it works or how the images are named I
guess that the names do not really end with T1, T2 etc. but with tif or
similar, so endsWith might not do what you think it does.

The last 2 lines appear split in the message. It should be 1 line.

for (i=1; i<=nImages; i++) {
  selectImage(i);
  title = getTitle();
  if (endsWith(title, "T1"))
      green=title;
  else if (endsWith(title, "T2"))
      red = title;
  else  if (endsWith(title, "T3"))
      blue=title;
  else if (endsWith(title, "T4"))
      gray=title; // not needed ?
}
run("Merge Channels...", "red=["+red+"] green=["+green+"] blue=["+blue+
"] gray=*None* create");


Cheers
G.