public class ChannelMasker extends Object
Four different types of operations are supported:
Constructor and Description |
---|
ChannelMasker(org.incenp.imagej.ChannelMasker.ChannelOperation[] operations)
Creates a new ChannelMasker object with the given list of operations.
|
Modifier and Type | Method and Description |
---|---|
ij.ImagePlus |
apply(ij.ImagePlus image,
String name)
Apply this ChannelMasker object to an image.
|
ij.ImagePlus |
apply(ij.ImagePlus image,
String name,
String order)
Apply this ChannelMasker object to an image.
|
static ij.ImagePlus |
applyMasker(ij.ImagePlus image,
String command,
String name,
String order)
Apply a list of operations to an image.
|
ChannelMasker |
chain(ChannelMasker next)
Sets a ChannelMasker to apply after the current one.
|
static ChannelMasker |
createMasker(String command)
Creates a ChannelMasker object from a text description of the operations.
|
static ChannelMasker |
createMasker(String command,
String order)
Creates a ChannelMasker object from a text description of the operations.
|
static ChannelMasker |
createMasker(String command,
String order,
int options)
Creates a ChannelMasker from a text description of the operations.
|
String |
getChannelOrder()
Gets the default channel order specification.
|
int |
getMaskingOptions()
Gets the masking options currently used by this object.
|
void |
setChannelOrder(String order)
Sets the default channel order specification.
|
void |
setMaskingOptions(int options)
Sets the masking options used by this object.
|
public ChannelMasker(org.incenp.imagej.ChannelMasker.ChannelOperation[] operations)
createMasker(String)
static method is the preferred high-level
interface to create a ChannelMasker.operations
- the list of operations to applypublic void setChannelOrder(String order)
createMasker(java.lang.String, java.lang.String, int)
method to refer to channels without
knowing the position of the channels in the images the masker will be applied
to.
For example, a masker object created with the "A:MASK(Huang),B:COPY()" command and applied to an image with channel order "ABC" will perform the MASK operation to the first channel and the COPY operation to the second channel; the same masker applied to an image with channel order "CADB" will perform the MASK operation on the second channel and the COPY operation to the fourth channel.
order
- the default channel order to use when applying the maskerpublic String getChannelOrder()
setChannelOrder(String)
public void setMaskingOptions(int options)
Masking
for available options. By default ChannelMasker objects uses
the CLOSE_OPEN_MASK option.options
- the new masking optionspublic int getMaskingOptions()
public ij.ImagePlus apply(ij.ImagePlus image, String name, String order)
image
- the source image to apply the operations toname
- the name to give to the new imageorder
- the order of channels in the source image (may be null, in which
case the default channel order will be used)public ij.ImagePlus apply(ij.ImagePlus image, String name)
image
- the source image to apply the operations toname
- the name to give to the new imagepublic ChannelMasker chain(ChannelMasker next)
apply(ij.ImagePlus, java.lang.String, java.lang.String)
method is called, the specified ChannelMasker will be applied to the
resulting image, and the output of that application is what will be returned.
The method returns the object it is called on, allowing to create a chain as follows:
CM1.chain(CM2.chain(CM3))
When CM1.apply(...)
is called, it will return the output of CM3
applied to the output of CM2 applied to the output of CM1 applied to the
original image.
next
- the ChannelMasker object to apply after this onepublic static ChannelMasker createMasker(String command, String order, int options)
ThresholdingMethod
for possible values of "algo"; values are matched
in a case-insensitive way). The optional "param" value is either the actual
threshold to use (when using the FIXED method) or the radius to consider when
using one of the local thresholding methods (defaulting to 15 if no value is
specified).
For example, the command "2:MASK(MaxEntropy),1:COPY()" will create a ChannelMasker that, when applied to an image, will produce an output image with two channels: the first channel will be a binary mask created by thresholding the second channel of the source image with the “Max Entropy” algorithm, and the second channel will be a copy of the first channel of the source image.
The command "2:APPLY(1)" will create a ChannelMasker that, when applied to an image, will produce an output image containing a single channel, which will be result of applying the binary mask found in the first channel of the source image to the second channel of that same image, with the AND operator.
The order parameter, if non-null, is expected to be a list of letters. Channels in the command string may then be specified by a letter from that list instead of a numerical index. The rationale behind this parameter is to allow to use command strings that are independent of the orders of the channels in the source image.
For example, if the order parameter is "GRB", then the command "R:MASK(MaxEntropy),G:COPY()" will be equivalent to the first example above.
command
- a text description of the operations to performorder
- the default channel order specification, as described in
setChannelOrder(String)
(may be null)options
- flags for masking operation (see constant fields in
Masking
for available flags)public static ChannelMasker createMasker(String command, String order)
createMasker(String, String, int)
but uses
the default option CLOSE_OPEN_MASK.command
- a text description of the operations to performorder
- the default channel order specification, as described in
setChannelOrder(String)
(may be null)public static ChannelMasker createMasker(String command)
createMasker(String, String)
but does not
allow to set a default channel order.command
- a text description of the operations to performpublic static ij.ImagePlus applyMasker(ij.ImagePlus image, String command, String name, String order)
createMasker(String, String)
method) directly to an image without
having to manipulate a ChannelMasker object.image
- the image to apply the operations tocommand
- the list of operations to applyname
- the name to give to the new imageorder
- the order of channels in the source image (may be null)Copyright © 2021. All rights reserved.