net.imglib2.realtransform.AffineTransform3D Java Examples

The following examples show how to use net.imglib2.realtransform.AffineTransform3D. 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: GlobalTransformManager.java    From paintera with GNU General Public License v2.0 7 votes vote down vote up
public synchronized void setTransform(final AffineTransform3D affine, final Duration duration) {
	if (duration.toMillis() == 0.0) {
		setTransform(affine);
		return;
	}
	final Timeline timeline = new Timeline(60.0);
	timeline.setCycleCount(1);
	timeline.setAutoReverse(false);
	final AffineTransform3D currentState = this.affine.copy();
	final DoubleProperty progressProperty = new SimpleDoubleProperty(0.0);
	final SimilarityTransformInterpolator interpolator = new SimilarityTransformInterpolator(currentState, affine.copy());
	progressProperty.addListener((obs, oldv, newv) -> setTransform(interpolator.interpolateAt(newv.doubleValue())));
	final KeyValue kv = new KeyValue(progressProperty, 1.0, Interpolator.EASE_BOTH);
	timeline.getKeyFrames().add(new KeyFrame(duration, kv));
	timeline.play();
}
 
Example #2
Source File: RestrictPainting.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param transform transforms voxel data into real world coordinates
 * @param priority in fetching queue
 * @param name initialize with this name
 * @param <T> data type
 * @param <V> viewer type
 * @return {@link DataSource}
 * @throws IOException if any N5 operation throws {@link IOException}
 */
public static <T extends NativeType<T> & RealType<T>, V extends Volatile<T> & NativeType<V> & RealType<V>>
DataSource<T, V> openRawAsSource(
		final N5Reader reader,
		final String dataset,
		final AffineTransform3D transform,
		final SharedQueue queue,
		final int priority,
		final String name) throws IOException, ReflectionException {
	return openScalarAsSource(
			reader,
			dataset,
			transform,
			queue,
			priority,
			i -> i == Interpolation.NLINEAR
			     ? new NLinearInterpolatorFactory<>()
			     : new NearestNeighborInterpolatorFactory<>(),
			i -> i == Interpolation.NLINEAR
			     ? new NLinearInterpolatorFactory<>()
			     : new NearestNeighborInterpolatorFactory<>(),
			name
	                         );
}
 
Example #4
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param transform transforms voxel data into real world coordinates
 * @param priority in fetching queue
 * @param name initialize with this name
 * @param <T> data type
 * @param <V> viewer type
 * @return {@link DataSource}
 * @throws IOException if any N5 operation throws {@link IOException}
 */
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
DataSource<T, V> openScalarAsSource(
		final N5Reader reader,
		final String dataset,
		final AffineTransform3D transform,
		final SharedQueue queue,
		final int priority,
		final String name) throws IOException, ReflectionException {
	return openScalarAsSource(
			reader,
			dataset,
			transform,
			queue,
			priority,
			i -> new NearestNeighborInterpolatorFactory<>(),
			i -> new NearestNeighborInterpolatorFactory<>(),
			name
	                         );
}
 
Example #5
Source File: ProcessForDeconvolution.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
private ExtractPSF<FloatType> loadPSFs(
		final Channel ch,
		final ArrayList< ViewDescription > allInputData,
		final HashMap< Channel, ArrayList< Pair< Pair< Angle, Illumination >, String > > > psfFiles,
		final boolean transformLoadedPSFs )
{
	final HashMap< ViewId, AffineTransform3D > models;
	
	if ( transformLoadedPSFs )
	{
		models = new HashMap< ViewId, AffineTransform3D >();
	
		for ( final ViewDescription viewDesc : allInputData )
			models.put( viewDesc, spimData.getViewRegistrations().getViewRegistration( viewDesc ).getModel() );
	}
	else
	{
		models = null;
	}

	return ExtractPSF.loadAndTransformPSFs( psfFiles.get( ch ), allInputData, new FloatType(), models );
}
 
Example #6
Source File: FloodFillTransformedCylinder3D.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static void fill(
		final AffineTransform3D localToWorld,
		final double radiusX,
		final double radiusY,
		final double zRangePos,
		final double zRangeNeg,
		final RandomAccess<? extends IntegerType<?>> localAccess,
		final RealLocalizable seedWorld,
		final long fillLabel)
{
	new FloodFillTransformedCylinder3D(localToWorld, radiusX, radiusY, zRangePos, zRangeNeg).fill(
			localAccess,
			seedWorld,
			fillLabel
	                                                                                             );
}
 
Example #7
Source File: OrthogonalViews.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static ViewerAndTransforms create(
		final GlobalTransformManager manager,
		final CacheControl cacheControl,
		final ViewerOptions optional,
		final ViewerAxis axis,
		final Function<Source<?>, Interpolation> interpolation)
{
	final AffineTransform3D globalToViewer = ViewerAxis.globalToViewer(axis);
	LOG.debug("Generating viewer, axis={}, globalToViewer={}", axis, globalToViewer);
	final ViewerPanelFX viewer = new ViewerPanelFX(
			1,
			cacheControl,
			optional,
			interpolation
	);
	final AffineTransformWithListeners displayTransform        = new AffineTransformWithListeners();
	final AffineTransformWithListeners globalToViewerTransform = new AffineTransformWithListeners(globalToViewer);

	return new ViewerAndTransforms(viewer, manager, displayTransform, globalToViewerTransform);
}
 
Example #8
Source File: IntersectingSourceStateDeserializer.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public IntersectingSourceStateDeserializer(
		final IntFunction<SourceState<?, ?>> dependsOn,
		final SharedQueue queue,
		final int priority,
		final Group meshesGroup,
		final ObjectProperty<ViewFrustum> viewFrustumProperty,
		final ObjectProperty<AffineTransform3D> eyeToWorldTransformProperty,
		final BooleanProperty viewerEnabled,
		final ExecutorService manager,
		final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> workers)
{
	super();
	this.dependsOn = dependsOn;
	this.queue = queue;
	this.priority = priority;
	this.meshesGroup = meshesGroup;
	this.viewFrustumProperty = viewFrustumProperty;
	this.eyeToWorldTransformProperty = eyeToWorldTransformProperty;
	this.viewerEnabled = viewerEnabled;
	this.manager = manager;
	this.workers = workers;
}
 
Example #9
Source File: N5ChannelDataSourceSerializer.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public JsonElement serialize(
		final N5ChannelDataSource<?, ?> s,
		final Type type,
		final JsonSerializationContext context)
{
	final JsonObject map = new JsonObject();
	map.addProperty(META_CLASS_KEY, s.meta().getClass().getName());
	map.add(META_KEY, context.serialize(s.meta()));
	final AffineTransform3D transform = new AffineTransform3D();
	s.getSourceTransform(0, 0, transform);
	map.add(TRANSFORM_KEY, context.serialize(transform));
	map.addProperty(CHANNEL_DIMENSION_KEY, s.getChannelDimension());
	map.add(CHANNELS_KEY, context.serialize(s.getChannels()));
	return map;
}
 
Example #10
Source File: SceneBlockTree.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static BlockTree<BlockTreeFlatKey, BlockTreeNode<BlockTreeFlatKey>> createSceneBlockTree(
		final DataSource<?, ?> source,
		final ViewFrustum viewFrustum,
		final AffineTransform3D eyeToWorldTransform,
		final int levelOfDetail,
		final int coarsestScaleLevel,
		final int finestScaleLevel,
		final CellGrid[] rendererGrids)
{
	return createSceneBlockTree(
			source,
			viewFrustum,
			eyeToWorldTransform,
			levelOfDetail,
			coarsestScaleLevel,
			finestScaleLevel,
			rendererGrids,
			() -> false
		);
}
 
Example #11
Source File: FractalSpimDataGenerator.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args)
{
	Interval start = new FinalInterval( new long[] {0,0,0},  new long[] {100, 100, 1});
	List<Interval> res = generateTileList( start, 3, 3, 0.2 );
	for (Interval i : res){
		System.out.println("(" + Long.toString( i.min( 0 )) + "," + Long.toString( i.min( 1 )) + ")");
	}
	
	final AffineTransform3D m = new AffineTransform3D();
	double scale = 300;
	m.set( scale, 0.0f, 0.0f, 0.0f, 
		   0.0f, scale, 0.0f, 0.0f,
		   0.0f, 0.0f, scale, 0.0f );
	
	FractalSpimDataGenerator fsdg = new FractalSpimDataGenerator(3);
	fsdg.addFractal( m );
	
	BigDataViewer.open(  fsdg.generateSpimData( res ), "", null, null );
	
	/*
	new ImageJ();
	RandomAccessibleInterval< LongType > rai = new FractalSpimDataGenerator( new AffineTransform2D() ).getImage( res.get( 0 ) );
	ImageJFunctions.show( rai );
	*/
}
 
Example #12
Source File: LabelSourceState.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static <D extends IntegerType<D> & NativeType<D>, T extends Volatile<D> & IntegerType<T>>
LabelSourceState<D, T> simpleSourceFromSingleRAI(
		final RandomAccessibleInterval<D> data,
		final double[] resolution,
		final double[] offset,
		final long maxId,
		final String name,
		final Group meshesGroup,
		final ObjectProperty<ViewFrustum> viewFrustumProperty,
		final ObjectProperty<AffineTransform3D> eyeToWorldTransformProperty,
		final ExecutorService meshManagerExecutors,
		final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> meshWorkersExecutors) {

	return simpleSourceFromSingleRAI(
			data,
			resolution,
			offset,
			new NoOpInvalidate<>(),
			maxId,
			name,
			meshesGroup,
			viewFrustumProperty,
			eyeToWorldTransformProperty,
			meshManagerExecutors,
			meshWorkersExecutors);
}
 
Example #13
Source File: ExportSpimData2TIFF.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
@Override
public < T extends RealType< T > & NativeType< T > > boolean exportImage( final RandomAccessibleInterval<T> img, final BoundingBoxGUI bb, final TimePoint tp, final ViewSetup vs, final double min, final double max )
{
	// write the image
	if ( !this.saver.exportImage( img, bb, tp, vs, min, max ) )
		return false;

	// update the registrations
	final ViewRegistration vr = spimData.getViewRegistrations().getViewRegistration( new ViewId( tp.getId(), vs.getId() ) );
	
	final double scale = bb.getDownSampling();
	final AffineTransform3D m = new AffineTransform3D();
	m.set( scale, 0.0f, 0.0f, bb.min( 0 ), 
		   0.0f, scale, 0.0f, bb.min( 1 ),
		   0.0f, 0.0f, scale, bb.min( 2 ) );
	final ViewTransform vt = new ViewTransformAffine( "fusion bounding box", m );

	vr.getTransformList().clear();
	vr.getTransformList().add( vt );
	
	return true;
}
 
Example #14
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
ImagesWithTransform<T, V> openRaw(
		final N5Reader reader,
		final String dataset,
		final double[] resolution,
		final double[] offset,
		final SharedQueue queue,
		final int priority) throws IOException
{
	final AffineTransform3D transform = new AffineTransform3D();
	transform.set(
			resolution[0], 0, 0, offset[0],
			0, resolution[1], 0, offset[1],
			0, 0, resolution[2], offset[2]
	             );
	return openRaw(reader, dataset, transform, queue, priority);
}
 
Example #15
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static <
		D extends RealType<D> & NativeType<D>,
		T extends AbstractVolatileRealType<D, T> & NativeType<T>> N5ChannelDataSource<D, T> valueExtended(
		final N5Meta meta,
		final AffineTransform3D transform,
		final String name,
		final SharedQueue queue,
		final int priority,
		final int channelDimension,
		final long[] channels,
		final double extension) throws IOException, DataTypeNotSupported {

	return extended(
			meta, transform,
			name,
			queue,
			priority,
			channelDimension,
			channels,
			d -> d.setReal(extension),
			t -> t.setReal(extension)
	);
}
 
Example #16
Source File: DisplayTransformUpdateOnResize.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private void setCanvasSize(final double width, final double height, final boolean updateTransform)
{
	if (width == 0 || height == 0)
		return;
	if (updateTransform) // && false )
	{
		synchronized (lock)
		{
			final AffineTransform3D transform = this.displayTransform;
			transform.set(0, 0, 3);
			transform.set(0, 1, 3);
			transform.scale(width / canvasW);
			transform.set(width / 2, 0, 3);
			transform.set(height / 2, 1, 3);
			displayTransformUpdater.setTransform(transform);
		}
	}
	canvasW = width;
}
 
Example #17
Source File: Rotate.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public Rotate(
		final DoubleSupplier speed,
		final AffineTransform3D globalTransform,
		final AffineTransform3D displayTransform,
		final AffineTransform3D globalToViewerTransform,
		final Consumer<AffineTransform3D> submitTransform,
		final Object lock)
{
	super();
	this.speed = speed;
	this.globalTransform = globalTransform;
	this.displayTransform = displayTransform;
	this.globalToViewerTransform = globalToViewerTransform;
	this.submitTransform = submitTransform;
	this.lock = lock;
}
 
Example #18
Source File: RandomAccessibleIntervalDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public RandomAccessibleIntervalDataSource(
		final RandomAccessibleInterval<D>[] dataSources,
		final RandomAccessibleInterval<T>[] sources,
		final AffineTransform3D[] mipmapTransforms,
		final Invalidate<Long> invalidate,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation,
		final Supplier<D> dataTypeSupplier,
		final Supplier<T> typeSupplier,
		final String name) {
	super();
	this.mipmapTransforms = mipmapTransforms;
	this.dataSources = dataSources;
	this.sources = sources;
	this.invalidate = invalidate;
	this.dataInterpolation = dataInterpolation;
	this.interpolation = interpolation;
	this.dataTypeSupplier = dataTypeSupplier;
	this.typeSupplier = typeSupplier;
	this.name = name;
}
 
Example #19
Source File: SegmentMeshCacheLoader.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public SegmentMeshCacheLoader(
		final Supplier<RandomAccessibleInterval<T>> data,
		final BiFunction<TLongHashSet, Double, Converter<T, BoolType>> getMaskGenerator,
		final AffineTransform3D transform)
{
	super(data, getMaskGenerator, transform);
}
 
Example #20
Source File: SimilarityTransformInterpolator.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public AffineTransform3D interpolateAt(final double t) {

		final double[] qDiffCurrent = new double[ 4 ];
		final double[] qCurrent = new double[ 4 ];
		LinAlgHelpers.quaternionPower( qDiff, t, qDiffCurrent );
		LinAlgHelpers.quaternionMultiply( qStart, qDiffCurrent, qCurrent );

		final double alpha = Math.pow( scaleRate, t );
		final double scaleCurrent = scaleStart * alpha;

		final double[] xg0Current = new double[ 3 ];
		final double[] tCurrent = new double[ 3 ];
		final double f = Math.abs( scaleRate - 1.0 ) < 0.0001 ? -t : ( scaleEnd / alpha - scaleEnd ) / scaleDiff;
		LinAlgHelpers.scale( xg0Diff, f, xg0Current );
		for ( int r = 0; r < 3; ++r )
			xg0Current[ r ] -= xg0Start[ r ];
		final double[][] Rcurrent = new double[ 3 ][ 3 ];
		LinAlgHelpers.quaternionToR( qCurrent, Rcurrent );
		LinAlgHelpers.mult( Rcurrent, xg0Current, tCurrent );

		final double[][] m = new double[ 3 ][ 4 ];
		for ( int r = 0; r < 3; ++r )
		{
			for ( int c = 0; c < 3; ++c )
				m[ r ][ c ] = scaleCurrent * Rcurrent[ r ][ c ];
			m[ r ][ 3 ] = scaleCurrent * tCurrent[ r ];
		}

		final AffineTransform3D transform = new AffineTransform3D();
		transform.set( m );
		return transform;
	}
 
Example #21
Source File: PaintUtils.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param labelToGlobalTransform
 * @param viewerTransform
 * @param axis
 * 		{@code 0=x, 1=y, 2=z}
 * @param tolerance
 * 		{@code 0 <= tolerance << 1}
 *
 * @return {@code -1} if axis no unique corresponding axis according to tolerance, else {@code 0=x, 1=y, 2=z}
 */
public static int labelAxisCorrespondingToViewerAxis(
		final AffineTransform3D labelToGlobalTransform,
		final AffineTransform3D viewerTransform,
		final int axis,
		final double tolerance)
{
	final double[] transformedAxis = viewerAxisInLabelCoordinates(labelToGlobalTransform, viewerTransform, axis);
	LinAlgHelpers.normalize(transformedAxis);
	if (Math.abs(Math.abs(transformedAxis[0]) - 1.0) <= tolerance) { return 0; }
	if (Math.abs(Math.abs(transformedAxis[1]) - 1.0) <= tolerance) { return 1; }
	if (Math.abs(Math.abs(transformedAxis[2]) - 1.0) <= tolerance) { return 2; }
	return -1;
}
 
Example #22
Source File: TransformInputAndWeights.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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 #23
Source File: TransformInput.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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 #24
Source File: DataSourceTest.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testGetScale()
{
	double[][] resolutions = {
			{1.0, 1.0, 1.0},
			{2.0, 3.0, 4.0},
			{6.0, 12.0, 20.0}
	};

	double[] zeroOffset = new double[] {0.0, 0.0, 0.0};
	double[] ratio = new double[3];

			AffineTransform3D[] transforms = Arrays
			.stream(resolutions)
			.map(r -> N5Helpers.fromResolutionAndOffset(r, zeroOffset))
			.toArray(AffineTransform3D[]::new);

	DummyDataSource source = new DummyDataSource(transforms);
	Assert.assertEquals(resolutions.length, source.getNumMipmapLevels());
	for (int level = 0; level < source.getNumMipmapLevels(); ++level)
	{
		Assert.assertArrayEquals(resolutions[level], DataSource.getScale(source, 0, level), 0.0);
		for (int targetLevel = 0; targetLevel < source.getNumMipmapLevels(); ++targetLevel)
		{
			ratio[0] = resolutions[targetLevel][0] / resolutions[level][0];
			ratio[1] = resolutions[targetLevel][1] / resolutions[level][1];
			ratio[2] = resolutions[targetLevel][2] / resolutions[level][2];
			LOG.debug("Ratio for {} {} is {}", level, targetLevel, ratio);
			Assert.assertArrayEquals(ratio, DataSource.getRelativeScales(source, 0, level, targetLevel), 0.0);
		}
	}


}
 
Example #25
Source File: TransformTracker.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public TransformTracker(
		final AffineTransform3D transform,
		final Consumer<AffineTransform3D> onChange,
		final Object lock)
{
	super();
	this.transform = transform;
	this.lock = lock;
	this.onChange = onChange;
}
 
Example #26
Source File: AbstractMeshCacheLoader.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public AbstractMeshCacheLoader(
		final Supplier<RandomAccessibleInterval<T>> data,
		final BiFunction<K, Double, Converter<T, BoolType>> getMaskGenerator,
		final AffineTransform3D transform)
{
	super();
	LOG.debug("Constructiong {}", getClass().getName());
	this.data = data;
	this.getMaskGenerator = getMaskGenerator;
	this.transform = transform;
}
 
Example #27
Source File: TransformTools.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static boolean nonTranslationsEqual(final ViewRegistration vr1, final ViewRegistration vr2)
{
	final int n = vr1.getModel().numDimensions();
	final AffineTransform3D dsTransform = new AffineTransform3D();
	
	final Pair< AffineGet, TranslationGet > initialTransforms1 = getInitialTransforms( vr1, n == 2, dsTransform );
	final Pair< AffineGet, TranslationGet > initialTransforms2 = getInitialTransforms( vr2, n == 2, dsTransform );
	
	return allAlmostEqual( initialTransforms1.getA().getRowPackedCopy(), initialTransforms2.getA().getRowPackedCopy(), 0.01 );
}
 
Example #28
Source File: RemoveRotation.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public void removeRotationCenteredAt(final double x, final double y)
{

	final double[] mouseLocation = new double[3];

	final RealPoint p = RealPoint.wrap(mouseLocation);
	p.setPosition(x, 0);
	p.setPosition(y, 1);
	p.setPosition(0, 2);

	final AffineTransform3D global = new AffineTransform3D();

	synchronized (lock)
	{
		global.set(globalTransform);
		viewerTransform.applyInverse(mouseLocation, mouseLocation);
	}
	final double[] inOriginalSpace = mouseLocation.clone();
	global.apply(mouseLocation, mouseLocation);

	final AffineTransform3D affine = new AffineTransform3D();
	for (int i = 0; i < affine.numDimensions(); ++i)
	{
		double val = 0.0;
		for (int k = 0; k < affine.numDimensions(); ++k)
		{
			final double entry = global.get(k, i);
			val += entry * entry;
		}
		val = Math.sqrt(val);
		affine.set(val, i, i);
		affine.set(mouseLocation[i] - inOriginalSpace[i] * val, i, 3);
	}
	LOG.debug("Updating transform to {}", affine);
	submitTransform.accept(affine);
}
 
Example #29
Source File: FloodFill.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
private void fillAt(final double x, final double y, final long fill)
{
	final ViewerState viewerState   = viewer.getState();

	// TODO should this check happen outside?
	if (!isVisible.getAsBoolean())
	{
		LOG.info("Selected source is not visible -- will not fill");
		return;
	}

	final int               level          = 0;
	final AffineTransform3D labelTransform = new AffineTransform3D();
	// TODO What to do for time series?
	final int               time           = 0;
	source.getSourceTransform(time, level, labelTransform);

	final RealPoint rp = setCoordinates(x, y, viewer, labelTransform);
	final Point     p  = new Point(rp.numDimensions());
	for (int d = 0; d < p.numDimensions(); ++d)
	{
		p.setPosition(Math.round(rp.getDoublePosition(d)), d);
	}

	LOG.debug("Filling source {} with label {} at {}", source, fill, p);
	try
	{
		fill(time, level, fill, p, assignment);
	} catch (final MaskInUse e)
	{
		LOG.info(e.getMessage());
	}

}
 
Example #30
Source File: DemoLinkOverlay.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public DemoLinkOverlay( PairwiseLinkInterface results, AbstractSpimData< ? > spimData )
{
	this.results = results;
	this.spimData = spimData;
	this.lastFilteredResults = new ArrayList<>();
	this.lastInconsistentResults = new ArrayList<>();
	viewerTransform = new AffineTransform3D();
	isActive = false;
	activeLinks = new ArrayList<>();
}