CompositeImage, Select specific channels to show


I am creating a pixel-wise classification application.
and for the annotation, I need to select the channels to show. this would help to know the category of the cell.
I have a composite image of 7 channels ( 4 image channels + 3 extra channels: masks, category, cell clicked).
and I would like to select which from this 7 channels to show in an optimized way.

Could someone help me? Please.

Hello Marwan -

I’m not exactly sure what your use case is, but you mention
CompositeImage and java, so perhaps the following might
be helpful.

You can use the CompositeImage java api to change which
channels are being displayed. For convenience, I illustrate this
using a jython (python) script, but you would do it the same way
in java, for example, in a java plugin.

The script:

from ij import IJ
from ij import CompositeImage ('Clown')   # get sample color image
imp = IJ.getImage()

# make a CompositeImage
ci = CompositeImage (imp, CompositeImage.COMPOSITE)
ci.setTitle ('clown_composite')

print  ci.getNChannels()   # ci has three channels

# turn off red and green channels; leave blue on
ci.getActiveChannels()[0] = False
ci.getActiveChannels()[1] = False

# flatten and save for forum
fi = ci.flatten()
fi.setTitle ('flat_clown')
IJ.saveAs (fi, 'PNG', 'flat_clown')

After you run this script, you should see displayed a composite
version of the “Clown” sample image (as well as the original and
flattened versions) with only its blue channel active.

Here is the image (flattened, for the forum) produced by the script:


Thanks, mm