Class MixedTransform
- All Implemented Interfaces:
Concatenable<Mixed>
,PreConcatenable<Mixed>
,BoundingBoxTransform
,Mixed
,Transform
It transform a n-dimensional source vector to a m-dimensional target vector, and can be represented as a m+1 × n+1 homogeneous matrix. The mixed transform can be decomposed as follows:
- project down (discard some components of the source vector)
- component permutation
- component inversion
- project up (add zero components in the target vector)
- translation
The project down and component permutation steps are implemented by the
component mapping
. This is a lookup array
that specifies for each target dimension from which source dimension it is
taken.
Note, that it is not allowed to set this array such that a source component
is mapped to several target components!
- Author:
- Tobias Pietzsch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int[]
for each component of the target vector (before translation).protected final boolean[]
for each component of the target vector (before translation).protected final int
dimension of source vector.protected final long[]
translation is added to the target vector after applying permutation, projection, inversion operations.protected final boolean[]
for each component of the target vector (before translation).Fields inherited from class net.imglib2.transform.integer.AbstractMixedTransform
numTargetDimensions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(int[] source, int[] target) Apply theTransform
to a source vector to obtain a target vector.void
apply
(long[] source, long[] target) Apply theTransform
to a source vector to obtain a target vector.void
apply
(Localizable source, Positionable target) concatenate
(Mixed t) Concatenate this object with a.void
getComponentInversion
(boolean[] invert) Get an array indicating for each target component, whether the source component it is taken from should be inverted.boolean
getComponentInversion
(int d) Get the d-th component of inversion vector (seeMixed.getComponentInversion(boolean[])
).int
getComponentMapping
(int d) Get the source dimension which is mapped to the d-th target dimension (seeMixed.getComponentMapping(int[])
).void
getComponentMapping
(int[] component) Get an array indicating for each target dimensions from which source dimension it is taken.void
getComponentZero
(boolean[] zero) Get a boolean array indicating which target dimensions are _not_ taken from source dimensions.boolean
getComponentZero
(int d) Get the d-th component of zeroing vector (seeMixed.getComponentZero(boolean[])
).double[][]
Get the matrix that transforms homogeneous source points to homogeneous target points.long
getTranslation
(int d) Get the d-th component of translation (seeMixed.getTranslation(long[])
).void
getTranslation
(long[] t) Get the translation.boolean
Check whether the transforms has a full mapping of source to target components (no source component is discarded).int
Returns n, the dimension of the source vector.Pre-concatenate this object with a.void
set parameters totransform
.void
setComponentInversion
(boolean[] invert) Set for each target component, whether the source component it is taken from should be inverted.void
setComponentMapping
(int[] component) Set for each target dimensions from which source dimension it is taken.void
setComponentZero
(boolean[] zero) Set which target dimensions are _not_ taken from source dimensions.void
setInverseTranslation
(long[] tinv) void
setTranslation
(long[] t) Methods inherited from class net.imglib2.transform.integer.AbstractMixedTransform
numTargetDimensions, transform
-
Field Details
-
numSourceDimensions
protected final int numSourceDimensionsdimension of source vector. -
translation
protected final long[] translationtranslation is added to the target vector after applying permutation, projection, inversion operations. -
zero
protected final boolean[] zerofor each component of the target vector (before translation). should the value be taken from a source vector component (false) or should it be zero (true). -
invert
protected final boolean[] invertfor each component of the target vector (before translation). should the source vector component be inverted (true). -
component
protected final int[] componentfor each component of the target vector (before translation). from which source vector component should it be taken.
-
-
Constructor Details
-
MixedTransform
public MixedTransform(int sourceDim, int targetDim)
-
-
Method Details
-
numSourceDimensions
public int numSourceDimensions()Description copied from interface:Transform
Returns n, the dimension of the source vector.- Specified by:
numSourceDimensions
in interfaceTransform
- Overrides:
numSourceDimensions
in classAbstractMixedTransform
- Returns:
- the dimension of the source vector.
-
getTranslation
public void getTranslation(long[] t) Description copied from interface:Mixed
Get the translation. Translation is added to the target vector after applying permutation, projection, inversion operations.- Specified by:
getTranslation
in interfaceMixed
- Overrides:
getTranslation
in classAbstractMixedTransform
- Parameters:
t
- array of size at least the target dimension to store the result.
-
getTranslation
public long getTranslation(int d) Description copied from interface:Mixed
Get the d-th component of translation (seeMixed.getTranslation(long[])
).- Specified by:
getTranslation
in interfaceMixed
- Overrides:
getTranslation
in classAbstractMixedTransform
-
setTranslation
public void setTranslation(long[] t) -
setInverseTranslation
public void setInverseTranslation(long[] tinv) -
getComponentZero
public void getComponentZero(boolean[] zero) Description copied from interface:Mixed
Get a boolean array indicating which target dimensions are _not_ taken from source dimensions.For instance, if the transform maps 2D (x,y) coordinates to the first two components of a 3D (x,y,z) coordinate, the result will be [false, false, true]
- Specified by:
getComponentZero
in interfaceMixed
- Overrides:
getComponentZero
in classAbstractMixedTransform
- Parameters:
zero
- array of size at least the target dimension to store the result.
-
getComponentZero
public boolean getComponentZero(int d) Description copied from interface:Mixed
Get the d-th component of zeroing vector (seeMixed.getComponentZero(boolean[])
).- Specified by:
getComponentZero
in interfaceMixed
- Overrides:
getComponentZero
in classAbstractMixedTransform
-
setComponentZero
public void setComponentZero(boolean[] zero) Set which target dimensions are _not_ taken from source dimensions.For instance, if the transform maps 2D (x,y) coordinates to the first two components of a 3D (x,y,z) coordinate, this will be [false, false, true]
- Parameters:
zero
- array that says for each component of the target vector (before translation) whether the value should be taken from a source vector component (false) or should be set to zero (true).
-
getComponentMapping
public void getComponentMapping(int[] component) Description copied from interface:Mixed
Get an array indicating for each target dimensions from which source dimension it is taken.For instance, if the transform maps 2D (x,y) coordinates to the first two components of a 3D (x,y,z) coordinate, the result will be [0, 1, x]. Here, the value of x is undefined because the third target dimension does not correspond to any source dimension. See
Mixed.getComponentZero(boolean[])
.- Specified by:
getComponentMapping
in interfaceMixed
- Overrides:
getComponentMapping
in classAbstractMixedTransform
- Parameters:
component
- array of size at least the target dimension to store the result.
-
getComponentMapping
public int getComponentMapping(int d) Description copied from interface:Mixed
Get the source dimension which is mapped to the d-th target dimension (seeMixed.getComponentMapping(int[])
).- Specified by:
getComponentMapping
in interfaceMixed
- Overrides:
getComponentMapping
in classAbstractMixedTransform
-
setComponentMapping
public void setComponentMapping(int[] component) Set for each target dimensions from which source dimension it is taken.For instance, if the transform maps 2D (x,y) coordinates to the first two components of a 3D (x,y,z) coordinate, this will be [0, 1, x]. Here, x can be any value because the third target dimension does not correspond to any source dimension, which can be realized using
setComponentZero(boolean[])
.Note, that it is not allowed to set the
component
array such that a source component is mapped to several target components!- Parameters:
component
- array that says for each component of the target vector (before translation) from which source vector component it should be taken.
-
getComponentInversion
public void getComponentInversion(boolean[] invert) Description copied from interface:Mixed
Get an array indicating for each target component, whether the source component it is taken from should be inverted.For instance, if rotating a 2D (x,y) coordinates by 180 degrees will map it to (-x,-y). In this case, the result will be [true, true].
- Specified by:
getComponentInversion
in interfaceMixed
- Overrides:
getComponentInversion
in classAbstractMixedTransform
- Parameters:
invert
- array of size at least the target dimension to store the result.
-
getComponentInversion
public boolean getComponentInversion(int d) Description copied from interface:Mixed
Get the d-th component of inversion vector (seeMixed.getComponentInversion(boolean[])
).- Specified by:
getComponentInversion
in interfaceMixed
- Overrides:
getComponentInversion
in classAbstractMixedTransform
-
setComponentInversion
public void setComponentInversion(boolean[] invert) Set for each target component, whether the source component it is taken from should be inverted.For instance, if rotating a 2D (x,y) coordinates by 180 degrees will map it to (-x,-y). In this case, this will be [true, true].
- Parameters:
invert
- array that says for each component of the target vector (before translation) whether the source vector component it is taken from should be inverted (true).
-
apply
public void apply(long[] source, long[] target) Description copied from interface:Transform
Apply theTransform
to a source vector to obtain a target vector. -
apply
public void apply(int[] source, int[] target) Description copied from interface:Transform
Apply theTransform
to a source vector to obtain a target vector. -
apply
Description copied from interface:Transform
-
concatenate
Description copied from interface:Concatenable
Concatenate this object with a. The result will be an object that can be concatenated with another A. The conventional meaning for concatenating transformations is the following: Let ba = b.concatenate(a). Applying ba to x is equivalent to first applying a to x and then applying b to the result.- Specified by:
concatenate
in interfaceConcatenable<Mixed>
-
getConcatenableClass
- Specified by:
getConcatenableClass
in interfaceConcatenable<Mixed>
-
preConcatenate
Description copied from interface:PreConcatenable
Pre-concatenate this object with a. The result will be an object that can be pre-concatenated with another A. The conventional meaning for concatenating transformations is the following: Let ba = a.preConcatenate(b). Applying ba to x is equivalent to first applying a to x and then applying b to the result.- Specified by:
preConcatenate
in interfacePreConcatenable<Mixed>
-
getPreConcatenableClass
- Specified by:
getPreConcatenableClass
in interfacePreConcatenable<Mixed>
-
set
set parameters totransform
.- Parameters:
transform
-
-
getMatrix
public double[][] getMatrix()Get the matrix that transforms homogeneous source points to homogeneous target points. For testing purposes. -
hasFullSourceMapping
public boolean hasFullSourceMapping()Check whether the transforms has a full mapping of source to target components (no source component is discarded).- Returns:
- whether there is a full mapping of source to target components.
-