How to merge more than 3 channel stack in plugin development?

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

How to merge more than 3 channel stack in plugin development?

Yinan Wan
Hi all,

Here is my problem: I am now developing a plugin to read a special raw format of 4d image, which has multiple(>3) color channels and there is a 3d stack represented by each color. Currently I can store each channel in an imagestack. But I do need a way to display them in one stack in different colors. Is there any method to merge these stacks of images into one? Note: what I mean by "merge" here is not to really them as into one RGB color image stack, but some way to construct a multi-channel hyperstack.

I know the compositeImage can somehow realize this, but the construction method is not clear in the api, could anyone please tell me how to use it?

ps: I do want to develop a plugin, not a macro, nor do I want to use a developed plugin. I am just looking for some programming tips

Thank you very much!!

Yinan
Reply | Threaded
Open this post in threaded view
|

Re: How to merge more than 3 channel stack in plugin development?

Nathaniel Ryckman
You could always look through the source:

http://rsbweb.nih.gov/ij/developer/source/ij/plugin/frame/Channels.java.html

Yinan Wan wrote
Hi all,

Here is my problem: I am now developing a plugin to read a special raw format of 4d image, which has multiple(>3) color channels and there is a 3d stack represented by each color. Currently I can store each channel in an imagestack. But I do need a way to display them in one stack in different colors. Is there any method to merge these stacks of images into one? Note: what I mean by "merge" here is not to really them as into one RGB color image stack, but some way to construct a multi-channel hyperstack.

I know the compositeImage can somehow realize this, but the construction method is not clear in the api, could anyone please tell me how to use it?

ps: I do want to develop a plugin, not a macro, nor do I want to use a developed plugin. I am just looking for some programming tips

Thank you very much!!

Yinan
Reply | Threaded
Open this post in threaded view
|

Re: How to merge more than 3 channel stack in plugin development?

Yinan Wan
Thank you Nathaniel. The source shows how a "compositeImage" works quite clearly. But the problem is that I don't have a compositeImage at hand. Should I construct a compositeImage from a imagePlus first?

Now that I have all these sigle-channel stacks. How should I build them into an imagePlus so that I can let the program know which image slices belong to which color channel?
Reply | Threaded
Open this post in threaded view
|

Re: How to merge more than 3 channel stack in plugin development?

Nathaniel Ryckman
Ah! I see. I think I understand what you want now.

1) You can run the command manually:

Image->Colors->Merge Channels

2) You can run the command through a Macro:

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

3) You can run the command through a plugin using the Macro interpreter:

IJ.run("Merge Channels...", "red=[pic.jpg (red)] green=[pic.jpg (green)] blue=[pic.jpg (blue)] gray=*None* create");

4) You can use pure Java without using the Macro interpreter (code not tested):

RGBStackMerge.mergeChannels(ImagePlus[] images, boolean keepSourceImages);

http://rsbweb.nih.gov/ij/developer/source/ij/plugin/RGBStackMerge.java.html

If you are doing a lot of plugin coding, I recommend downloading the imageJ source. I personally have set up an eclipse project with the source. It saves me from spending loads of time to look up commands.

To help me find classes that I am interested in, I use IJ_Props.txt and ij.Menus.java. IJ_Props.txt contains all the submenu classes. ij.Menus.java contains all the top level menu items.

http://rsbweb.nih.gov/ij/download/src/

Good luck!

Yinan Wan wrote
Thank you Nathaniel. The source shows how a "compositeImage" works quite clearly. But the problem is that I don't have a compositeImage at hand. Should I construct a compositeImage from a imagePlus first?

Now that I have all these sigle-channel stacks. How should I build them into an imagePlus so that I can let the program know which image slices belong to which color channel?
Reply | Threaded
Open this post in threaded view
|

Re: How to merge more than 3 channel stack in plugin development?

Yinan Wan
Thank you so much!!

Now the problem is solved. I just built an imagePlus array for each stack and simply used RGBStackMerge.mergeChannels to get a multi-channel hyperstack.

You are right. Reading the source code DOES help.
Reply | Threaded
Open this post in threaded view
|

Re: How to merge more than 3 channel stack in plugin development?

Nathaniel Ryckman
Nice . I'm glad it worked!

Yinan Wan wrote
Thank you so much!!

Now the problem is solved. I just built an imagePlus array for each stack and simply used RGBStackMerge.mergeChannels to get a multi-channel hyperstack.

You are right. Reading the source code DOES help.