Java Code Examples for net.imglib2.realtransform.AffineTransform3D#applyInverse()
The following examples show how to use
net.imglib2.realtransform.AffineTransform3D#applyInverse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TranslateAlongNormal.java From paintera with GNU General Public License v2.0 | 6 votes |
public void scroll(final double step) { synchronized (lock) { final double[] delta = {0, 0, Math.signum(step) * translationSpeed.getAsDouble ()}; final AffineTransform3D affine = global.copy(); final AffineTransform3D rotationAndScalingOnly = worldToSharedViewerSpace.copy(); rotationAndScalingOnly.setTranslation(0, 0, 0); rotationAndScalingOnly.applyInverse(delta, delta); LOG.debug("Translating by delta={}", delta); affine.set(affine.get(0, 3) + delta[0], 0, 3); affine.set(affine.get(1, 3) + delta[1], 1, 3); affine.set(affine.get(2, 3) + delta[2], 2, 3); manager.setTransform(affine); } }
Example 2
Source File: FloodFill.java From paintera with GNU General Public License v2.0 | 6 votes |
private static <P extends RealLocalizable & RealPositionable> P setCoordinates( final double x, final double y, final P location, final ViewerPanelFX viewer, final AffineTransform3D labelTransform) { location.setPosition(x, 0); location.setPosition(y, 1); location.setPosition(0, 2); viewer.displayToGlobalCoordinates(location); labelTransform.applyInverse(location, location); return location; }
Example 3
Source File: PaintUtils.java From paintera with GNU General Public License v2.0 | 6 votes |
/** * @param labelToGlobalTransform * @param viewerTransform * @param axis * {@code 0=x, 1=y, 2=z} * @param length * {@code != 0} * * @return */ public static double[] viewerAxisInLabelCoordinates( final AffineTransform3D labelToGlobalTransform, final AffineTransform3D viewerTransform, final int axis, final double length) { final AffineTransform3D labelToGlobalTransformWithoutTranslation = duplicateWithoutTranslation(labelToGlobalTransform); final AffineTransform3D viewerTransformWithoutTranslation = duplicateWithoutTranslation(viewerTransform); final AffineTransform3D labelToViewerTransformWithoutTranslation = labelToGlobalTransformWithoutTranslation.preConcatenate(viewerTransformWithoutTranslation); final double[] viewerUnitAxis = {0.0, 0.0, 0.0}; viewerUnitAxis[axis] = length; labelToViewerTransformWithoutTranslation.applyInverse(viewerUnitAxis, viewerUnitAxis); return viewerUnitAxis; }
Example 4
Source File: RestrictPainting.java From paintera with GNU General Public License v2.0 | 6 votes |
private static <P extends RealLocalizable & RealPositionable> P setCoordinates( final double x, final double y, final P location, final ViewerPanelFX viewer, final AffineTransform3D labelTransform) { location.setPosition(x, 0); location.setPosition(y, 1); location.setPosition(0, 2); viewer.displayToGlobalCoordinates(location); labelTransform.applyInverse(location, location); return location; }
Example 5
Source File: TransformTools.java From BigStitcher with GNU General Public License v2.0 | 6 votes |
/** * * @param vr the ViewRegistration to decompose * @param is2d true or false * @param dsCorrectionT downsampling correction * @return (1) the ViewRegistration without Translation part and the translation, with the inverse of (1) and dsCorrection applied */ public static Pair<AffineGet, TranslationGet> getInitialTransforms( final ViewRegistration vr, final boolean is2d, final AffineTransform3D dsCorrectionT ) { AffineTransform3D model = vr.getModel().copy(); // get model without translation (last column set to 0) AffineTransform3D modelWithoutTranslation = model.copy(); modelWithoutTranslation.set( 0, 0, 3 ); modelWithoutTranslation.set( 0, 1, 3 ); modelWithoutTranslation.set( 0, 2, 3 ); // the translation with inverse of other part of model applied final double[] target = model.getTranslation(); modelWithoutTranslation.applyInverse( target, target ); // we go from big to downsampled, thats why the inverse dsCorrectionT.applyInverse( target, target ); if ( is2d ) return new ValuePair<>(modelWithoutTranslation, new Translation2D( target[ 0 ], target[ 1 ] )); else return new ValuePair<>(modelWithoutTranslation, new Translation3D( target[ 0 ], target[ 1 ], target[ 2 ] )); }
Example 6
Source File: ViewerPanelFX.java From paintera with GNU General Public License v2.0 | 5 votes |
/** * Set {@code pos} to the display coordinates (x,y,0)<sup>T</sup> transformed into the source coordinate system. * * @param pos * is set to the source coordinates at display (x,y,0)<sup>T</sup>. */ public <P extends RealLocalizable & RealPositionable> void displayToSourceCoordinates( final double x, final double y, final AffineTransform3D sourceTransform, final P pos) { pos.setPosition(x, 0); pos.setPosition(y, 1); pos.setPosition(0, 2); displayToGlobalCoordinates(pos); sourceTransform.applyInverse(pos, pos); }
Example 7
Source File: PaintUtils.java From paintera with GNU General Public License v2.0 | 5 votes |
/** * This should be equivalent to {@link #maximumVoxelDiagonalLengthPerDimension(AffineTransform3D, * AffineTransform3D)}. * * @param labelToGlobalTransform * @param viewerTransform * * @return */ public static double[] labelUnitLengthAlongViewerAxis( final AffineTransform3D labelToGlobalTransform, final AffineTransform3D viewerTransform) { final AffineTransform3D labelToGlobalTransformWithoutTranslation = duplicateWithoutTranslation(labelToGlobalTransform); final AffineTransform3D viewerTransformWithoutTranslation = duplicateWithoutTranslation(viewerTransform); final AffineTransform3D labelToViewerTransformWithoutTranslation = labelToGlobalTransformWithoutTranslation.preConcatenate(viewerTransformWithoutTranslation); final double[] unitX = {1.0, 0.0, 0.0}; final double[] unitY = {0.0, 1.0, 0.0}; final double[] unitZ = {0.0, 0.0, 1.0}; labelToViewerTransformWithoutTranslation.applyInverse(unitX, unitX); labelToViewerTransformWithoutTranslation.applyInverse(unitY, unitY); labelToViewerTransformWithoutTranslation.applyInverse(unitZ, unitZ); LinAlgHelpers.normalize(unitX); LinAlgHelpers.normalize(unitY); LinAlgHelpers.normalize(unitZ); labelToViewerTransformWithoutTranslation.apply(unitX, unitX); labelToViewerTransformWithoutTranslation.apply(unitY, unitY); labelToViewerTransformWithoutTranslation.apply(unitZ, unitZ); return new double[] { unitX[0], unitY[1], unitZ[2] }; }
Example 8
Source File: TransformInputAndWeights.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
private static final void loop( final Cursor< FloatType > cursor, final Cursor< FloatType > cursorW, final RealRandomAccess< FloatType > ir, final RealRandomAccess< FloatType > wr, final AffineTransform3D transform, final float[] s, final float[] t, final int offsetX, final int offsetY, final int offsetZ, final int imgSizeX, final int imgSizeY, final int imgSizeZ ) { // move img cursor forward any get the value (saves one access) final FloatType v = cursor.next(); cursor.localize( s ); // move weight cursor forward and get the value final FloatType w = cursorW.next(); s[ 0 ] += offsetX; s[ 1 ] += offsetY; s[ 2 ] += offsetZ; transform.applyInverse( t, s ); if ( FusionHelper.intersects( t[ 0 ], t[ 1 ], t[ 2 ], imgSizeX, imgSizeY, imgSizeZ ) ) { ir.setPosition( t ); // do not accept 0 values in the data where image data is present, 0 means no image data is available // (used in MVDeconvolution.computeQuotient) v.set( Math.max( MVDeconvolution.minValue, ir.get().get() ) ); } // compute weights in any case (the border can be negative!) wr.setPosition( t ); w.set( wr.get() ); }
Example 9
Source File: TransformInput.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
private static final void loop( final Cursor< FloatType > cursor, final RealRandomAccess< FloatType > ir, final AffineTransform3D transform, final float[] s, final float[] t, final int offsetX, final int offsetY, final int offsetZ, final int imgSizeX, final int imgSizeY, final int imgSizeZ ) { // move img cursor forward any get the value (saves one access) final FloatType v = cursor.next(); cursor.localize( s ); s[ 0 ] += offsetX; s[ 1 ] += offsetY; s[ 2 ] += offsetZ; transform.applyInverse( t, s ); if ( FusionHelper.intersects( t[ 0 ], t[ 1 ], t[ 2 ], imgSizeX, imgSizeY, imgSizeZ ) ) { ir.setPosition( t ); // do not accept 0 values in the data where image data is present, 0 means no image data is available // (used in MVDeconvolution.computeQuotient) v.set( Math.max( MVDeconvolution.minValue, ir.get().get() ) ); } }
Example 10
Source File: OrthogonalCrossSectionsIntersect.java From paintera with GNU General Public License v2.0 | 4 votes |
public static void getCenter(final AffineTransform3D transform, final double[] center) { Arrays.fill(center, 0); transform.applyInverse(center, center); }
Example 11
Source File: Geom3DUtils.java From paintera with GNU General Public License v2.0 | 2 votes |
/** * Returns distance from the camera to a point. * * Note that for performance reasons the {@code point} parameter will be modified by this method! * * @param cameraToWorldTransform * @param point * @return */ public static double distanceFromCamera(final AffineTransform3D cameraToWorldTransform, final RealPoint point) { cameraToWorldTransform.applyInverse(point, point); return length(point); }
Example 12
Source File: Geom3DUtils.java From paintera with GNU General Public License v2.0 | 2 votes |
/** * Returns the Z plane coordinate in camera space where the point is located. * * Note that for performance reasons the {@code point} parameter will be modified by this method! * * @param cameraToWorldTransform * @param point * @return */ public static double cameraZPlane(final AffineTransform3D cameraToWorldTransform, final RealPoint point) { cameraToWorldTransform.applyInverse(point, point); return point.getDoublePosition(2); }