public class SequenceUtil extends java.lang.Object
Sequence
utilities class.Modifier and Type | Class and Description |
---|---|
static class |
SequenceUtil.AddTHelper |
static class |
SequenceUtil.AddZHelper |
static class |
SequenceUtil.AdjustZTHelper |
static class |
SequenceUtil.MergeCHelper |
static class |
SequenceUtil.MergeTHelper |
static class |
SequenceUtil.MergeZHelper |
Constructor and Description |
---|
SequenceUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addT(Sequence sequence,
int num)
Add one or severals frames at position t.
|
static void |
addT(Sequence sequence,
int num,
boolean copyLast)
Add one or severals frames at position t.
|
static void |
addT(Sequence sequence,
int t,
int num)
Add one or severals frames at position t.
|
static void |
addT(Sequence sequence,
int t,
int num,
int copyLast)
Add one or severals frames at position t.
|
static void |
addZ(Sequence sequence,
int num)
Add one or severals slices at position z.
|
static void |
addZ(Sequence sequence,
int num,
boolean copyLast)
Add one or severals slices at position z.
|
static void |
addZ(Sequence sequence,
int z,
int num)
Add one or severals slices at position z.
|
static void |
addZ(Sequence sequence,
int z,
int num,
int copyLast)
Add one or severals slices at position z.
|
static void |
adjustZT(Sequence sequence,
int newSizeZ,
int newSizeT,
boolean reverseOrder)
Adjust Z and T dimension of the sequence.
|
static Sequence |
concatC(Sequence[] sequences)
Create and returns a new sequence by concatenating all given sequences on C dimension.
|
static Sequence |
concatC(Sequence[] sequences,
boolean fillEmpty,
boolean rescale)
Create and returns a new sequence by concatenating all given sequences on C dimension.
|
static Sequence |
concatC(Sequence[] sequences,
boolean fillEmpty,
boolean rescale,
ProgressListener pl)
Create and returns a new sequence by concatenating all given sequences on C dimension.
|
static Sequence |
concatC(Sequence[] sequences,
int[] channels,
boolean fillEmpty,
boolean rescale,
ProgressListener pl)
Create and returns a new sequence by concatenating all given sequences on C dimension.
|
static Sequence |
concatT(Sequence[] sequences)
Create and returns a new sequence by concatenating all given sequences on T dimension.
|
static Sequence |
concatT(Sequence[] sequences,
boolean interlaced,
boolean fillEmpty,
boolean rescale)
Create and returns a new sequence by concatenating all given sequences on T dimension.
|
static Sequence |
concatT(Sequence[] sequences,
boolean interlaced,
boolean fillEmpty,
boolean rescale,
ProgressListener pl)
Create and returns a new sequence by concatenating all given sequences on T dimension.
|
static Sequence |
concatZ(Sequence[] sequences)
Create and returns a new sequence by concatenating all given sequences on Z dimension.
|
static Sequence |
concatZ(Sequence[] sequences,
boolean interlaced,
boolean fillEmpty,
boolean rescale)
Create and returns a new sequence by concatenating all given sequences on Z dimension.
|
static Sequence |
concatZ(Sequence[] sequences,
boolean interlaced,
boolean fillEmpty,
boolean rescale,
ProgressListener pl)
Create and returns a new sequence by concatenating all given sequences on Z dimension.
|
static Sequence |
convertColor(Sequence source,
int imageType,
LUT lut)
Do color conversion of the specified
Sequence into the specified type. |
static java.awt.geom.Point2D |
convertPoint(java.awt.geom.Point2D pt,
int inputResolution,
int outputResolution)
Convert the given Point2D coordinate from an input resolution and a wanted output resolution level (0/1/2/3/...)
|
static java.awt.geom.Point2D |
convertPoint(java.awt.geom.Point2D pt,
Sequence source,
Sequence destination)
|
static Point3D |
convertPoint(Point3D pt,
Sequence source,
Sequence destination)
|
static java.awt.geom.Rectangle2D |
convertRectangle(java.awt.geom.Rectangle2D rect,
int inputResolution,
int outputResolution)
Convert the given Rectangle2D from an input resolution and a wanted output resolution level (0/1/2/3/...)
|
static java.awt.geom.Rectangle2D |
convertRectangle(java.awt.geom.Rectangle2D rect,
Sequence source,
Sequence destination)
|
static Rectangle3D |
convertRectangle(Rectangle3D rect,
Sequence source,
Sequence destination)
|
static void |
convertToStack(Sequence sequence)
Set all images of the sequence in Z dimension.
|
static void |
convertToTime(Sequence sequence)
Set all images of the sequence in T dimension.
|
static Sequence |
convertToType(Sequence source,
DataType dataType,
boolean rescale)
Converts the source sequence to the specified data type.
|
static Sequence |
convertToType(Sequence source,
DataType dataType,
boolean rescale,
boolean useDataBounds)
Converts the source sequence to the specified data type.
|
static Sequence |
convertToType(Sequence source,
DataType dataType,
Scaler scaler)
Deprecated.
Use
convertType(Sequence, DataType, Scaler[]) instead. |
static void |
convertToVolume(Sequence sequence)
Deprecated.
Use
convertToStack(Sequence) instead. |
static Sequence |
convertType(Sequence source,
DataType dataType,
Scaler[] scalers)
Converts the source sequence to the specified data type.
|
static Sequence |
extractChannel(Sequence source,
int channel)
Build a new single channel sequence (grey) from the specified channel of the source sequence.
|
static Sequence |
extractChannels(Sequence source,
int... channels)
Build a new sequence by extracting the specified channels from the source sequence.
|
static Sequence |
extractChannels(Sequence source,
java.util.List<java.lang.Integer> channels)
Deprecated.
Use
extractChannels(Sequence, int...) instead. |
static Sequence |
extractFrame(Sequence source,
int t)
Build a new sequence by extracting the specified T frame from the source sequence.
|
static Sequence |
extractSlice(Sequence source,
int z)
Build a new sequence by extracting the specified Z slice from the source sequence.
|
static Sequence |
getCopy(Sequence source)
Creates and return a copy of the sequence.
|
static Sequence |
getCopy(Sequence source,
boolean copyROI,
boolean copyOverlay,
boolean nameSuffix)
Creates and return a copy of the sequence.
|
static int |
getMaxDim(Sequence[] sequences,
DimensionId dim)
Returns the max size of specified dimension for the given sequences.
|
static java.awt.Point |
getOriginPoint(java.awt.Point pt,
Sequence source)
Convert the given Point coordinate from the source Sequence into the original image coordinate (pixel)
This method use the Sequence.getOriginResolution() and Sequence.getOriginXYRegion() informations
to compute the original image position. |
static java.awt.Rectangle |
getOriginRectangle(java.awt.Rectangle rect,
Sequence source)
Convert the given Rectangle region from the source Sequence into the original image region coordinates
(pixel)
This method use the Sequence.getOriginResolution() and Sequence.getOriginXYRegion() informations
to compute the original image region coordinates. |
static Sequence |
getSubSequence(Sequence source,
int startX,
int startY,
int startZ,
int startT,
int sizeX,
int sizeY,
int sizeZ,
int sizeT)
Deprecated.
|
static Sequence |
getSubSequence(Sequence source,
int startX,
int startY,
int startC,
int startZ,
int startT,
int sizeX,
int sizeY,
int sizeC,
int sizeZ,
int sizeT)
Deprecated.
|
static Sequence |
getSubSequence(Sequence source,
Rectangle5D.Integer region)
Creates a new sequence from the specified region of the source sequence.
|
static Sequence |
getSubSequence(Sequence source,
ROI roi)
Creates a new sequence which is a sub part of the source sequence defined by the specified
ROI bounds. |
static Sequence |
getSubSequence(Sequence source,
ROI roi,
double nullValue)
Creates a new sequence which is a sub part of the source sequence defined by the specified
ROI
bounds. |
static void |
moveT(Sequence sequence,
int t,
int newT)
Modify frame position.
|
static void |
moveT(Sequence sequence,
int from,
int to,
int offset)
Modify T position of a range of frame by the specified offset
|
static void |
moveZ(Sequence sequence,
int z,
int newZ)
Modify slice position.
|
static void |
moveZ(Sequence sequence,
int from,
int to,
int offset)
Modify Z position of a range of slice by the specified offset
|
static void |
removeChannel(Sequence source,
int channel)
Remove the specified channel from the source sequence.
|
static void |
removeT(Sequence sequence,
int t)
Remove a frame at position t.
|
static void |
removeTAndShift(Sequence sequence,
int t)
Remove a frame at position t and shift all the further t by -1.
|
static void |
removeZ(Sequence sequence,
int z)
Remove a slice at position Z.
|
static void |
removeZAndShift(Sequence sequence,
int z)
Remove a slice at position t and shift all the further t by -1.
|
static void |
reverseT(Sequence sequence)
Reverse T frames order.
|
static void |
reverseZ(Sequence sequence)
Reverse Z slices order.
|
static Sequence |
rotate(Sequence source,
double angle)
Return a rotated version of the source Sequence with specified parameters.
|
static Sequence |
rotate(Sequence source,
double xOrigin,
double yOrigin,
double angle,
IcyBufferedImageUtil.FilterType filterType)
Return a rotated version of the source sequence with specified parameters.
|
static Sequence |
rotate(Sequence source,
double angle,
IcyBufferedImageUtil.FilterType filterType)
Return a rotated version of the source Sequence with specified parameters.
|
static Sequence |
scale(Sequence source,
int width,
int height)
Return a copy of the sequence with specified size.
|
static Sequence |
scale(Sequence source,
int width,
int height,
boolean resizeContent,
int xAlign,
int yAlign)
Return a copy of the sequence with specified size.
|
static Sequence |
scale(Sequence source,
int width,
int height,
boolean resizeContent,
int xAlign,
int yAlign,
IcyBufferedImageUtil.FilterType filterType)
Return a copy of the source sequence with specified size, alignment rules and filter type.
|
static Sequence |
scale(Sequence source,
int width,
int height,
IcyBufferedImageUtil.FilterType filterType)
Return a copy of the sequence with specified size.
|
static void |
swapT(Sequence sequence,
int t1,
int t2)
Exchange 2 frames position on the sequence.
|
static void |
swapZ(Sequence sequence,
int z1,
int z2)
Exchange 2 slices position on the sequence.
|
static Sequence |
toARGB(Sequence source)
Convert the specified sequence to ARGB sequence (4 channels)
|
static Sequence |
toGray(Sequence source)
Convert the specified sequence to gray sequence (single channel)
|
static Sequence |
toRGB(Sequence source)
Convert the specified sequence to RGB sequence (3 channels)
|
public SequenceUtil()
public static void addT(Sequence sequence, int t, int num, int copyLast)
t
- Position where to add frame(s)num
- Number of frame to addcopyLast
- Number of last frame(s) to copy to fill added frames.public static void addT(Sequence sequence, int t, int num)
t
- Position where to add frame(s)num
- Number of frame to addpublic static void addT(Sequence sequence, int num)
num
- Number of frame to addpublic static void addT(Sequence sequence, int num, boolean copyLast)
num
- Number of frame to addcopyLast
- If true then the last frame is copied in added frames.public static void swapT(Sequence sequence, int t1, int t2)
public static void moveT(Sequence sequence, int t, int newT)
newT
position is lost.sequence
- t
- current t positionnewT
- wanted t positionpublic static void moveT(Sequence sequence, int from, int to, int offset)
sequence
- from
- start of range (t position)to
- end of range (t position)offset
- position shiftpublic static void removeT(Sequence sequence, int t)
sequence
- t
- public static void removeTAndShift(Sequence sequence, int t)
sequence
- t
- public static void addZ(Sequence sequence, int z, int num, int copyLast)
z
- Position where to add slice(s)num
- Number of slice to addcopyLast
- Number of last slice(s) to copy to fill added slices.public static void addZ(Sequence sequence, int z, int num)
z
- Position where to add slice(s)num
- Number of slice to addpublic static void addZ(Sequence sequence, int num)
num
- Number of slice to addpublic static void addZ(Sequence sequence, int num, boolean copyLast)
num
- Number of slice to addcopyLast
- If true then the last slice is copied in added slices.public static void swapZ(Sequence sequence, int z1, int z2)
public static void moveZ(Sequence sequence, int z, int newZ)
newZ
position is lost.sequence
- z
- current z positionnewZ
- wanted z positionpublic static void moveZ(Sequence sequence, int from, int to, int offset)
sequence
- from
- start of range (z position)to
- end of range (z position)offset
- position shiftpublic static void removeZ(Sequence sequence, int z)
sequence
- z
- public static void removeZAndShift(Sequence sequence, int z)
sequence
- z
- public static void convertToTime(Sequence sequence)
public static void convertToStack(Sequence sequence)
@Deprecated public static void convertToVolume(Sequence sequence)
convertToStack(Sequence)
instead.public static void removeChannel(Sequence source, int channel)
source
- Source sequencechannel
- Channel index to removepublic static int getMaxDim(Sequence[] sequences, DimensionId dim)
public static Sequence concatC(Sequence[] sequences, int[] channels, boolean fillEmpty, boolean rescale, ProgressListener pl) throws java.lang.IllegalArgumentException
sequences
- Sequences to concatenate (use array order).channels
- Selected channel for each sequence (channels.length = sequences.length
)sequences
parameter :sequences[n] = Sequence1; channels[n] = 0;
sequences[n+1] = Sequence1; channels[n+1] = 2;
...
fillEmpty
- Replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.pl
- ProgressListener to indicate processing progress.java.lang.IllegalArgumentException
- if sequences contains incompatible sequence for merge operation.public static Sequence concatC(Sequence[] sequences, boolean fillEmpty, boolean rescale, ProgressListener pl)
sequences
- Sequences to concatenate (use array order).fillEmpty
- Replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.pl
- ProgressListener to indicate processing progress.public static Sequence concatC(Sequence[] sequences, boolean fillEmpty, boolean rescale)
sequences
- Sequences to concatenate (use array order).fillEmpty
- Replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.public static Sequence concatC(Sequence[] sequences)
sequences
- Sequences to concatenate (use array order).public static Sequence concatZ(Sequence[] sequences, boolean interlaced, boolean fillEmpty, boolean rescale, ProgressListener pl)
sequences
- Sequences to concatenate (use array order).interlaced
- Interlace images.fillEmpty
- Replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.pl
- ProgressListener to indicate processing progress.public static Sequence concatZ(Sequence[] sequences, boolean interlaced, boolean fillEmpty, boolean rescale)
sequences
- Sequences to concatenate (use array order).interlaced
- Interlace images.fillEmpty
- Replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.public static Sequence concatZ(Sequence[] sequences)
sequences
- Sequences to concatenate (use array order).public static Sequence concatT(Sequence[] sequences, boolean interlaced, boolean fillEmpty, boolean rescale, ProgressListener pl)
sequences
- sequences to concatenate (use array order).interlaced
- interlace images.fillEmpty
- replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.pl
- ProgressListener to indicate processing progress.public static Sequence concatT(Sequence[] sequences, boolean interlaced, boolean fillEmpty, boolean rescale)
sequences
- Sequences to concatenate (use array order).interlaced
- Interlace images.fillEmpty
- Replace empty image by the previous non empty one.rescale
- Images are scaled to all fit in the same XY dimension.public static Sequence concatT(Sequence[] sequences)
sequences
- Sequences to concatenate (use array order).public static void adjustZT(Sequence sequence, int newSizeZ, int newSizeT, boolean reverseOrder)
reverseOrder
- Means that images are T-Z ordered instead of Z-T orderednewSizeZ
- New Z size of the sequencenewSizeT
- New T size of the sequencepublic static Sequence extractChannel(Sequence source, int channel)
source
- Source sequencechannel
- Channel index to extract from the source sequence.@Deprecated public static Sequence extractChannels(Sequence source, java.util.List<java.lang.Integer> channels)
extractChannels(Sequence, int...)
instead.public static Sequence extractChannels(Sequence source, int... channels)
source
- Source sequencechannels
- Channel indexes to extract from the source sequence.public static Sequence extractSlice(Sequence source, int z)
source
- Source sequencez
- Slice index to extract from the source sequence.public static Sequence extractFrame(Sequence source, int t)
source
- Source sequencet
- Frame index to extract from the source sequence.public static Sequence convertToType(Sequence source, DataType dataType, boolean rescale, boolean useDataBounds)
source
- Source sequence to convertdataType
- Data type wantedrescale
- Indicate if we want to scale data value according to data (or data type) rangeuseDataBounds
- Only used when rescale
parameter is true.public static Sequence convertToType(Sequence source, DataType dataType, boolean rescale)
source
- Source sequence to convertdataType
- data type wantedrescale
- indicate if we want to scale data value according to data type range@Deprecated public static Sequence convertToType(Sequence source, DataType dataType, Scaler scaler)
convertType(Sequence, DataType, Scaler[])
instead.public static Sequence convertType(Sequence source, DataType dataType, Scaler[] scalers)
source
- Source sequence to convertdataType
- data type wanted.scalers
- scalers for scaling internal data during conversion (1 scaler per channel).null
to avoid value conversion.public static Sequence rotate(Sequence source, double xOrigin, double yOrigin, double angle, IcyBufferedImageUtil.FilterType filterType)
source
- source imagexOrigin
- X origin for the rotationyOrigin
- Y origin for the rotationangle
- rotation angle in radianfilterType
- filter resampling method usedpublic static Sequence rotate(Sequence source, double angle, IcyBufferedImageUtil.FilterType filterType)
source
- source imageangle
- rotation angle in radianfilterType
- filter resampling method usedpublic static Sequence rotate(Sequence source, double angle)
source
- source imageangle
- rotation angle in radianpublic static Sequence scale(Sequence source, int width, int height, boolean resizeContent, int xAlign, int yAlign, IcyBufferedImageUtil.FilterType filterType)
source
- source sequenceresizeContent
- indicate if content should be resized or not (empty area are 0 filled)xAlign
- horizontal image alignment (SwingConstants.LEFT / CENTER / RIGHT)yAlign
- vertical image alignment (SwingConstants.TOP / CENTER / BOTTOM)filterType
- filter method used for scale (used only if resizeContent is true)public static Sequence scale(Sequence source, int width, int height, boolean resizeContent, int xAlign, int yAlign)
source
- source sequenceresizeContent
- indicate if content should be resized or not (empty area are 0 filled)xAlign
- horizontal image alignment (SwingConstants.LEFT / CENTER / RIGHT)yAlign
- vertical image alignment (SwingConstants.TOP / CENTER / BOTTOM)public static Sequence scale(Sequence source, int width, int height, IcyBufferedImageUtil.FilterType filterType)
source
- source sequencefilterType
- filter method used for scale (used only if resizeContent is true)public static Sequence scale(Sequence source, int width, int height)
public static Sequence getSubSequence(Sequence source, Rectangle5D.Integer region)
@Deprecated public static Sequence getSubSequence(Sequence source, int startX, int startY, int startC, int startZ, int startT, int sizeX, int sizeY, int sizeC, int sizeZ, int sizeT)
getSubSequence(Sequence, icy.type.rectangle.Rectangle5D.Integer)
instead.@Deprecated public static Sequence getSubSequence(Sequence source, int startX, int startY, int startZ, int startT, int sizeX, int sizeY, int sizeZ, int sizeT)
getSubSequence(Sequence, icy.type.rectangle.Rectangle5D.Integer)
instead.public static Sequence getSubSequence(Sequence source, ROI roi, double nullValue)
ROI
bounds.source
- the source sequenceroi
- used to define to region to retain.nullValue
- the returned sequence is created by using the ROI rectangular bounds.nullValue
is different of Double.NaN
then any pixel
outside the ROI region will be set to nullValue
public static Sequence getSubSequence(Sequence source, ROI roi)
ROI
bounds.public static Sequence getCopy(Sequence source, boolean copyROI, boolean copyOverlay, boolean nameSuffix)
source
- the source sequence to copycopyROI
- Copy the ROI from source sequence.copyOverlay
- Copy the Overlay from source sequence.nameSuffix
- add the suffix " (copy)" to the new Sequence name to distinguish itpublic static Sequence getCopy(Sequence source)
public static Sequence toGray(Sequence source)
public static Sequence toRGB(Sequence source)
public static Sequence toARGB(Sequence source)
public static Sequence convertColor(Sequence source, int imageType, LUT lut)
Sequence
into the specified type.source
- source sequenceimageType
- wanted image type, only the following is accepted :lut
- lut used for color calculation (source sequence lut is used if null)public static java.awt.geom.Point2D convertPoint(java.awt.geom.Point2D pt, int inputResolution, int outputResolution)
Sequence.getOriginResolution()
public static java.awt.geom.Rectangle2D convertRectangle(java.awt.geom.Rectangle2D rect, int inputResolution, int outputResolution)
Sequence.getOriginResolution()
public static Point3D convertPoint(Point3D pt, Sequence source, Sequence destination)
source
Sequence
to the destination
Sequence
.Sequence.getPosition()
and Sequence.getPixelSize()
information to do the coordinate conversion.public static java.awt.geom.Point2D convertPoint(java.awt.geom.Point2D pt, Sequence source, Sequence destination)
source
Sequence
to the destination
Sequence
.Sequence.getPosition()
and Sequence.getPixelSize()
information to do the coordinate conversion.public static Rectangle3D convertRectangle(Rectangle3D rect, Sequence source, Sequence destination)
Rectangle3D
from the source
Sequence
to the destination
Sequence
.Sequence.getPosition()
and Sequence.getPixelSize()
information to do the coordinate conversion.public static java.awt.geom.Rectangle2D convertRectangle(java.awt.geom.Rectangle2D rect, Sequence source, Sequence destination)
Rectangle2D
from the source
Sequence
to the destination
Sequence
.Sequence.getPosition()
and Sequence.getPixelSize()
information to do the coordinate conversion.public static java.awt.Point getOriginPoint(java.awt.Point pt, Sequence source)
Sequence.getOriginResolution()
and Sequence.getOriginXYRegion()
informations
to compute the original image position.public static java.awt.Rectangle getOriginRectangle(java.awt.Rectangle rect, Sequence source)
Sequence.getOriginResolution()
and Sequence.getOriginXYRegion()
informations
to compute the original image region coordinates.