Merging Channels from 2 Images Macro

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

Merging Channels from 2 Images Macro

Timbleton
Hi,

I'm trying to write a macro that will allow me to merge two images together into two different channels - one into red and one into green. I'm not sure what should be put in for red= and green= once the two images are opened so that it works for any image, rather than the ones I used when I recorded the macro originally. Any help would be greatly appreciated. Thanks.

This is what I've got so far:
path = getDirectory("Choose a Directory");
filename = getFileList(path);
for (i=0; i<filename.length; i++) {
open(path+filename[i]);
for (i=1; i<filename.length; i++) {
open(path+filename[i]);
dir2 = getDirectory("Choose Destination Directory");


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

rename(filename[i]+"_merged");
saveAs("tiff", dir2+getTitle);
close();
 

Reply | Threaded
Open this post in threaded view
|

Re: Merging Channels from 2 Images Macro

Volker Baecker
Hello,
you need to put in the titles of the images. Store them in a variable
after opening the image.
For example something like this:

open(path+filename[i]);

redImage = getTitle();

....

run("Merge Channels...", "red=[" + redImage + "] green=[" + greenImage +"] blue=*None* gray=*None*");

Best regards,
Volker


On 20/08/12 21:22, Timbleton wrote:

> Hi,
>
> I'm trying to write a macro that will allow me to merge two images together
> into two different channels - one into red and one into green. I'm not sure
> what should be put in for red= and green= once the two images are opened so
> that it works for any image, rather than the ones I used when I recorded the
> macro originally. Any help would be greatly appreciated. Thanks.
>
> This is what I've got so far:
> path = getDirectory("Choose a Directory");
> filename = getFileList(path);
> for (i=0; i<filename.length; i++) {
> open(path+filename[i]);
> for (i=1; i<filename.length; i++) {
> open(path+filename[i]);
> dir2 = getDirectory("Choose Destination Directory");
>
>
> run("Merge Channels...", "red=[___] green=[___] blue=*None* gray=*None*");
>
> rename(filename[i]+"_merged");
> saveAs("tiff", dir2+getTitle);
> close();
>  
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/Merging-Channels-from-2-Images-Macro-tp4999813.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html