net.imglib2.util.Pair Java Examples

The following examples show how to use net.imglib2.util.Pair. 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: AbstractImgLoader.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates one specific ViewSetup using the imageMetaDataCache
 * 
 * @param setup - {@link ViewSetup}s that can potentially be updated if it is in the cache
 * @param forceUpdate - overwrite the data if it is already present
 * @return true if something was updated, false if it was not in the cache or if could have been updated but was already there
 */
public boolean updateXMLMetaData( final ViewSetup setup, final boolean forceUpdate )
{
	boolean updated = false;
	
	if ( viewIdLookUp.containsKey( setup.getId() ) )
	{
		// look up the metadata using the ViewId linked by the ViewSetupId
		final Pair< Dimensions, VoxelDimensions > metaData = imageMetaDataCache.get( viewIdLookUp.get( setup.getId() ) );

		if ( !setup.hasSize() || forceUpdate )
		{
			setup.setSize( metaData.getA() );
			updated = true;
		}

		if ( !setup.hasVoxelSize() || forceUpdate )
		{
			setup.setVoxelSize( metaData.getB() );
			updated = true;
		}
	}
	
	return updated;
}
 
Example #2
Source File: DefaultMinMax.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Pair<I, I> calculate(final Iterable<I> input) {
	double tmpMin = Double.POSITIVE_INFINITY;
	double tmpMax = Double.NEGATIVE_INFINITY;

	for (final I in : input) {
		final double n = in.getRealDouble();

		if (tmpMin > n) {
			tmpMin = n;
		}

		if (tmpMax < n) {
			tmpMax = n;
		}
	}

	final I min = input.iterator().next().createVariable();
	min.setReal(tmpMin);

	final I max = input.iterator().next().createVariable();
	max.setReal(tmpMax);

	return new ValuePair<>(min, max);
}
 
Example #3
Source File: SpimDataFilteringAndGrouping.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public List<Pair<? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup > >, ? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup >>>> getComparisons()
{
	final List<Pair<? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup > >, ? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup >>>> res = new ArrayList<>();
	
	// filter first
	final List<BasicViewDescription< ? > > ungroupedElements =
			SpimDataTools.getFilteredViewDescriptions( data.getSequenceDescription(), filters);
	// then group
	final List< Group< BasicViewDescription< ?  > >> groupedElements = 
			Group.combineBy(ungroupedElements, groupingFactors);
	
	// go through possible group pairs
	for (int i = 0; i < groupedElements.size(); ++i)
		for(int j = i+1; j < groupedElements.size(); ++j)
		{
			// we will want to process the pair if:
			// the groups do not differ along an axis along which we want to treat elements individually (e.g. Angle)
			// but they differ along an axis that we want to register (e.g Tile)
			if (!groupsDifferByAny( groupedElements.get( i ), groupedElements.get( j ), axesOfApplication ) 
					&& groupsDifferByAny( groupedElements.get( i ), groupedElements.get( j ), axesOfComparison ))
				res.add(new ValuePair<>(groupedElements.get( i ), groupedElements.get( j )));
		}
	return res;
}
 
Example #4
Source File: SkewImages.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public static List<AffineTransform3D> getAccumulativeSkewTransform(final List<AffineTransform3D> currentTransforms, final int skewDirection, final int alongAxis, final double angle)
{
	final List<AffineTransform3D> res = new ArrayList<>();

	for (final AffineTransform3D currentTransform : currentTransforms)
	{
		final Pair< AffineGet, AffineGet > decomp = TransformTools.decomposeIntoAffineAndTranslation( currentTransform );

		final AffineTransform3D skew = new AffineTransform3D();
		skew.set( Math.tan( angle ), skewDirection, alongAxis );
		// transformation order should be: 
		// move to origin -> inverse affine to axis-aligned pixels -> skew -> re-apply affine -> re-apply translation
		skew.concatenate( decomp.getA().inverse() );
		skew.concatenate( decomp.getB().inverse() );
		skew.preConcatenate( decomp.getA() );
		skew.preConcatenate( decomp.getB() );

		res.add( skew );
	}

	return res;
}
 
Example #5
Source File: FlipAxes.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public static List<AffineTransform3D> getAccumulativeFlipTransform(final List<AffineTransform3D> currentTransforms, final boolean[] flipAxes)
{
	final List<AffineTransform3D> res = new ArrayList<>();

	for (final AffineTransform3D currentTransform : currentTransforms)
	{
		final Pair< AffineGet, AffineGet > decomp = TransformTools.decomposeIntoAffineAndTranslation( currentTransform );

		final AffineTransform3D flip = new AffineTransform3D();
		for (int d=0; d<3; d++)
		{
			if (flipAxes[d])
				flip.set( -1, d, d );
		}
		// transformation order should be: 
		// move to origin -> inverse affine to axis-aligned pixels -> flip -> re-apply affine -> re-apply translation
		flip.concatenate( decomp.getA().inverse() );
		flip.concatenate( decomp.getB().inverse() );
		flip.preConcatenate( decomp.getA() );
		flip.preConcatenate( decomp.getB() );

		res.add( flip );
	}

	return res;
}
 
Example #6
Source File: InterestPointExplorer.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void save()
{
	for ( final Pair< InterestPointList, ViewId > list : panel.delete )
	{
		IOFunctions.println( "Deleting correspondences and interestpoints in timepointid=" + list.getB().getTimePointId() + ", viewid=" + list.getB().getViewSetupId() );

		final File ip = new File( list.getA().getBaseDir(), list.getA().getFile().toString() + list.getA().getInterestPointsExt() );
		final File corr = new File( list.getA().getBaseDir(), list.getA().getFile().toString() + list.getA().getCorrespondencesExt() );

		if ( ip.delete() )
			IOFunctions.println( "Deleted: " + ip.getAbsolutePath() );
		else
			IOFunctions.println( "FAILED to delete: " + ip.getAbsolutePath() );

		if ( corr.delete() )
			IOFunctions.println( "Deleted: " + corr.getAbsolutePath() );
		else
			IOFunctions.println( "FAILED to delete: " + corr.getAbsolutePath() );
	}

	//panel.save.clear();
	panel.delete.clear();
}
 
Example #7
Source File: DefaultPearsons.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected Accumulator(final Iterable<Pair<T, U>> samples, boolean substract, double xDiff, double yDiff) {

			for (Pair<T, U> sample : samples) {

				double value1 = sample.getA().getRealDouble();
				double value2 = sample.getB().getRealDouble();

				if (substract) {
					value1 -= xDiff;
					value2 -= yDiff;
				}

				x += value1;
				y += value2;
				xx += value1 * value1;
				xy += value1 * value2;
				yy += value2 * value2;
				count++;
			}
		}
 
Example #8
Source File: NormalizeIIFunction.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private double[] getBounds(final IterableInterval<T> input) {
	// the four elements are source min, source max, target min, and target max.
	final double[] result = new double[4];
	if (minMaxFunc != null) {
		final Pair<T, T> minMax = minMaxFunc.calculate(input);
		result[0] = (sourceMin == null ? minMax.getA() : sourceMin)
			.getRealDouble();
		result[1] = (sourceMax == null ? minMax.getB() : sourceMax)
			.getRealDouble();
	}
	else {
		result[0] = sourceMin.getRealDouble();
		result[1] = sourceMax.getRealDouble();
	}
	final T first = input.firstElement();
	result[2] = targetMin == null ? first.getMinValue() : targetMin
		.getRealDouble();
	result[3] = targetMax == null ? first.getMaxValue() : targetMax
		.getRealDouble();
	return result;
}
 
Example #9
Source File: NormalizeIIFunction.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize() {
	// If isLazy is false, the getBounds() will never be called, and the worker
	// is always used to do the work of compute(...)
	if (isLazy) {
		if (sourceMin == null || sourceMax == null) minMaxFunc =
			(UnaryFunctionOp) Functions.unary(ops(), Ops.Stats.MinMax.class,
				Pair.class, in());
	}
	else {
		super.initialize();
	}
	imgCreator = (UnaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class,
		IterableInterval.class, in());
}
 
Example #10
Source File: Resave_HDF5.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
public static Pair< SpimData2, List< String > > createXMLObject(
		final SpimData2 spimData,
		final List< ViewId > viewIds,
		final Parameters params,
		final ProgressWriter progressWriter,
		final boolean useRightAway )
{
	// Re-assemble a new SpimData object containing the subset of viewsetups and timepoints selected
	final List< String > filesToCopy = new ArrayList< String >();
	final SpimData2 newSpimData = Resave_TIFF.assemblePartialSpimData2( spimData, viewIds, params.seqFile.getParentFile(), filesToCopy );
	final ArrayList< Partition > partitions = Generic_Resave_HDF5.getPartitions( newSpimData, params );

	final Hdf5ImageLoader hdf5Loader;

	if ( useRightAway )
		hdf5Loader = new Hdf5ImageLoader( params.hdf5File, partitions, newSpimData.getSequenceDescription(), true );
	else
		hdf5Loader = new Hdf5ImageLoader( params.hdf5File, partitions, null, false );
	
	newSpimData.getSequenceDescription().setImgLoader( hdf5Loader );
	newSpimData.setBasePath( params.seqFile.getParentFile() );

	return new ValuePair< SpimData2, List< String > >( newSpimData, filesToCopy );
}
 
Example #11
Source File: DemoLinkOverlay.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void selectedViewDescriptions(
		List< List< BasicViewDescription< ? extends BasicViewSetup > > > viewDescriptions)
{
	List<Pair<Group<ViewId>, Group<ViewId>>> res = new ArrayList<>();
	for (int i = 0; i<viewDescriptions.size(); i++)
		for (int j = i+1; j<viewDescriptions.size(); j++)
		{
			Group<ViewId> groupA = new Group<>();
			groupA.getViews().addAll( viewDescriptions.get( i ) );
			Group<ViewId> groupB = new Group<>();
			groupB.getViews().addAll( viewDescriptions.get( j ) );
			res.add( new ValuePair< Group<ViewId>, Group<ViewId> >( groupA, groupB ) );
		}
	setActiveLinks( res );
}
 
Example #12
Source File: AutomaticReorientation.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected Pair< Integer, Integer > numReorientated()
{
	final ViewRegistrations vrs = spimData.getViewRegistrations();

	int isReorientated = 0;
	int sumViews = 0;

	for ( final ViewId viewId : viewIdsToProcess )
	{
		final ViewDescription vd = spimData.getSequenceDescription().getViewDescription( viewId );
		
		if ( !vd.isPresent() )
			continue;

		final ViewRegistration vr = vrs.getViewRegistration( viewId );
		final ViewTransform vt = vr.getTransformList().get( 0 );

		++sumViews;

		if ( vt.hasName() && vt.getName().startsWith( reorientationDescription ) )
				++isReorientated;
	}

	return new ValuePair< Integer, Integer >( isReorientated, sumViews );
}
 
Example #13
Source File: MeshGeneratorJobManager.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public MeshGeneratorJobManager(
		final int numScaleLevels,
		final T identifier,
		final ObservableMap<ShapeKey<T>, Pair<MeshView, Node>> meshesAndBlocks,
		final Pair<Group, Group> meshesAndBlocksGroups,
		final MeshViewUpdateQueue<T> meshViewUpdateQueue,
		final GetBlockListFor<T> getBlockLists,
		final GetMeshFor<T> getMeshes,
		final IntFunction<AffineTransform3D> unshiftedWorldTransforms,
		final ExecutorService managers,
		final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> workers,
		final IndividualMeshProgress meshProgress)
{
	this.identifier = identifier;
	this.meshesAndBlocks = meshesAndBlocks;
	this.meshesAndBlocksGroups = meshesAndBlocksGroups;
	this.meshViewUpdateQueue = meshViewUpdateQueue;
	this.getBlockLists = getBlockLists;
	this.getMeshes = getMeshes;
	this.unshiftedWorldTransforms = unshiftedWorldTransforms;
	this.managers = managers;
	this.workers = workers;
	this.numScaleLevels = numScaleLevels;
	this.meshesAndBlocks.addListener(this::handleMeshListChange);
	this.meshProgress = meshProgress;
}
 
Example #14
Source File: AutomaticReorientation.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected Pair< double[], double[] > determineSizeSimple( final ArrayList< ChannelProcess > channelsToUse, final int detections )
{
	final List< double[] > points = getAllDetectionsInGlobalCoordinates( channelsToUse, detections );

	if ( points.size() < 1 )
	{
		IOFunctions.println( "At least one point is required. Stopping" );
		return null;
	}

	final double[] min = points.get( 0 ).clone();
	final double[] max = min.clone();

	for ( final double[] p : points )
		for ( int d = 0; d < p.length; ++d )
		{
			min[ d ] = Math.min( min[ d ], p[ d ] );
			max[ d ] = Math.max( max[ d ], p[ d ] );
		}

	IOFunctions.println( "Min (direct): " + Util.printCoordinates( min ) );
	IOFunctions.println( "Max (direct): " + Util.printCoordinates( max ) );

	return new ValuePair< double[], double[] >( min, max );
}
 
Example #15
Source File: CommitCanvasN5.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static TLongHashSet generateContainedLabelsSet(
		final RandomAccessibleInterval<Pair<UnsignedLongType, LabelMultisetType>> relevantData)
{
	final TLongHashSet currentDataAsSet = new TLongHashSet();
	for (final Pair<UnsignedLongType, LabelMultisetType> p : Views.iterable(relevantData))
	{
		final UnsignedLongType  pa  = p.getA();
		final LabelMultisetType pb  = p.getB();
		final long              pav = pa.getIntegerLong();
		if (pav == Label.INVALID)
		{
			pb
					.entrySet()
					.stream()
					.map(Entry::getElement)
					.mapToLong(Label::id)
					.forEach(currentDataAsSet::add);
		}
		else
		{
			currentDataAsSet.add(pav);
		}
	}
	return currentDataAsSet;
}
 
Example #16
Source File: NormalizeTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testNormalize() {

	Img<ByteType> in = generateByteArrayTestImg(true, 5, 5);
	Img<ByteType> out = in.factory().create(in, new ByteType());

	ops.run(NormalizeIIComputer.class, out, in);

	final Pair<ByteType, ByteType> minMax2 = ops.stats().minMax(out);

	assertEquals(minMax2.getA().get(), Byte.MIN_VALUE);
	assertEquals(minMax2.getB().get(), Byte.MAX_VALUE);

	final IterableInterval<ByteType> lazyOut = ops.image().normalize(in);
	final IterableInterval<ByteType> notLazyOut = ops.image().normalize(in,
		null, null, null, null, false);

	final Cursor<ByteType> outCursor = out.cursor();
	final Cursor<ByteType> lazyCursor = lazyOut.cursor();
	final Cursor<ByteType> notLazyCursor = notLazyOut.cursor();
	while (outCursor.hasNext()) {
		assertEquals(outCursor.next().get(), lazyCursor.next().get());
		assertEquals(outCursor.get().get(), notLazyCursor.next().get());
	}
}
 
Example #17
Source File: PhaseCorrelationTest2.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args)
{
	RandomAccessibleInterval<  FloatType > image1 = ImgLib2Util.openAs32Bit( new File( "73.tif.zip" ) );
	RandomAccessibleInterval<  FloatType > image2 = ImgLib2Util.openAs32Bit( new File( "73m5-10-13.tif.zip" ) );
	//RandomAccessibleInterval<  FloatType > image2 = ImgLib2Util.openAs32Bit( new File( "73m5,75-10,25-12,6.tif.zip" ) );
	
	image1 = Downsample.downsample( image1, new long[] {4,4,2} );
	image2 = Downsample.downsample( image2, new long[] {4,4,2} );
	
	//Img<  FloatType > image1 = ImgLib2Util.openAs32Bit( new File( "boats.tif" ) );
	//Img<  FloatType > image2 = ImgLib2Util.openAs32Bit( new File( "boatsm10,5-m20,5.tif" ) );
	//Img<  FloatType > image2 = ImgLib2Util.openAs32Bit( new File( "boatsm5,75-10,25.tif" ) );
	
	
	//new ImageJ();
	/*
	SpimData mySd = GenerateSpimData.grid3x2();
	RandomAccessibleInterval< UnsignedShortType > image1 = (RandomAccessibleInterval< UnsignedShortType >) mySd.getSequenceDescription()
																				.getImgLoader().getSetupImgLoader( 0 ).getImage( 0, null );
	RandomAccessibleInterval< UnsignedShortType > image2 = (RandomAccessibleInterval< UnsignedShortType >) mySd.getSequenceDescription()
			.getImgLoader().getSetupImgLoader( 1 ).getImage( 0, null );
	
	//ImageJFunctions.show( image1 );
	//ImageJFunctions.show( image2 );
	*/
	Translation3D translation2 = new Translation3D(0, 0, 0);
	
	PairwiseStitchingParameters params = new PairwiseStitchingParameters();
	params.doSubpixel = true;
	
	Pair< Translation, Double > shift = PairwiseStitching.getShift( image1, image2,
								new Translation3D(),
								translation2, 
								params,
								Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors() ) );
	
	System.out.println( Util.printCoordinates( shift.getA().getTranslationCopy() ));
	System.out.print( shift.getB() );
}
 
Example #18
Source File: MeshGeneratorJobManager.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private void setMeshVisibility(final Pair<MeshView, Node> meshAndBlock, final boolean isVisible)
{
	if (meshAndBlock.getA() != null)
		meshAndBlock.getA().setVisible(isVisible);

	if (meshAndBlock.getB() != null)
		meshAndBlock.getB().setVisible(isVisible);
}
 
Example #19
Source File: MeshViewUpdateQueue.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private MeshViewQueueEntry(
		final Pair<MeshView, Node> meshAndBlockToAdd,
		final Pair<Group, Group> meshAndBlockGroup,
		final Runnable onCompleted)
{
	this.meshAndBlockToAdd = meshAndBlockToAdd;
	this.meshAndBlockGroup = meshAndBlockGroup;
	this.onCompleted = onCompleted;
}
 
Example #20
Source File: GeomNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.geom.geom2d.DefaultMaximumFeret.class)
public Pair<RealLocalizable, RealLocalizable> maximumFeret(final Polygon2D in) {
	@SuppressWarnings("unchecked")
	final Pair<RealLocalizable, RealLocalizable> result =
		(Pair<RealLocalizable, RealLocalizable>) ops().run(net.imagej.ops.geom.geom2d.DefaultMaximumFeret.class, in);
	return result;
}
 
Example #21
Source File: LinkExplorerRemoveLinkPopup.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e)
{
	final Pair< Group<ViewId>, Group<ViewId> > pair = panel.getModel().getActiveLinks().get( panel.getTable().getSelectedRow() );
	results.removePairwiseResultForPair( pair );
	((StitchingExplorerPanel< ?, ? >)stitchingExplorer).updateBDVPreviewMode();
	
	panel.selectedViewDescriptions( new ArrayList<>(((GroupedRowWindow)stitchingExplorer).selectedRowsGroups()) );
	panel.getModel().fireTableDataChanged();
}
 
Example #22
Source File: HistogramCreate.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Histogram1d<T> calculate(final Iterable<T> input) {
	final Pair<T, T> res = minMaxFunc.calculate(input);

	final Histogram1d<T> histogram1d = new Histogram1d<>(
			new Real1dBinMapper<T>(res.getA().getRealDouble(), res.getB()
					.getRealDouble(), numBins, false));

	histogram1d.countData(input);

	return histogram1d;
}
 
Example #23
Source File: InterestPointExplorerPanel.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public InterestPointExplorerPanel( final ViewInterestPoints viewInterestPoints, final ViewSetupExplorer< ?, ? > viewSetupExplorer )
{
	//this.save = new ArrayList< Pair< InterestPointList, ViewId > >();
	this.delete = new ArrayList< Pair< InterestPointList, ViewId > >();

	this.viewSetupExplorer = viewSetupExplorer;
	initComponent( viewInterestPoints );
}
 
Example #24
Source File: PairwiseStitching.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static <T extends RealType< T >, C extends Comparable< C >> List< PairwiseStitchingResult< C > > getPairwiseShifts(
		final Map< C, RandomAccessibleInterval< T > > rais, final Map< C, TranslationGet > translations,
		final PairwiseStitchingParameters params, final ExecutorService service)
{
	List< C > indexes = new ArrayList< >( rais.keySet() );
	Collections.sort( indexes );

	List< PairwiseStitchingResult< C > > result = new ArrayList< >();

	// got through all pairs with index1 < index2
	for ( int i = 0; i < indexes.size(); i++ )
	{
		for ( int j = i + 1; j < indexes.size(); j++ )
		{
			final Pair< Translation, Double > resT = getShift( rais.get( indexes.get( i ) ), rais.get( indexes.get( j ) ),
					translations.get( indexes.get( i ) ), translations.get( indexes.get( j ) ), params, service );

			if ( resT != null )
			{
				Set<C> setA = new HashSet<>();
				setA.add( indexes.get( i ) );
				Set<C> setB = new HashSet<>();
				setA.add( indexes.get( j ) );
				Pair< Group<C>, Group<C> > key = new ValuePair<>(new Group<>(setA), new Group<>(setB));
				result.add( new PairwiseStitchingResult< C >( key, null, resT.getA(), resT.getB(), 0.0 ) );
			}
		}
	}

	return result;

}
 
Example #25
Source File: TransformTools.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static Pair<AffineGet, AffineGet> decomposeIntoAffineAndTranslation(AffineGet tr)
{
	AffineTransform3D t = new AffineTransform3D();
	t.set( tr.getRowPackedCopy() );
	t.set( 0, 0, 3 );
	t.set( 0, 1, 3 );
	t.set( 0, 2, 3 );
	AffineTransform3D tt = new AffineTransform3D();
	tt.set( tr.get( 0, 3 ), 0, 3 );
	tt.set( tr.get( 1, 3 ), 1, 3 );
	tt.set( tr.get( 2, 3 ), 2, 3 );
	
	return new ValuePair< AffineGet, AffineGet >( t, tt );
}
 
Example #26
Source File: Apply_Transformation.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run( final String arg0 )
{
	// ask for everything
	final LoadParseQueryXML result = new LoadParseQueryXML();

	if ( !result.queryXML( "applying a transformation", "Apply to", true, true, true, true ) )
		return;

	final SpimData2 data = result.getData();
	final List< ViewId > viewIds = SpimData2.getAllViewIdsSorted( result.getData(), result.getViewSetupsToProcess(), result.getTimePointsToProcess() );

	final ApplyParameters params = queryParams( data, viewIds );

	if ( params == null )
		return;

	final Map< ViewDescription, Pair< double[], String > > modelLinks;

	// query models and apply them
	if ( params.defineAs == 0 ) // matrix
		modelLinks = queryString( data, viewIds, params );
	else if ( params.defineAs == 1 ) //Rotation around axis
		modelLinks = queryRotationAxis( data, viewIds, params );
	else // Interactively using the BigDataViewer
		modelLinks = queryBigDataViewer( data, viewIds, params );

	if ( modelLinks == null )
		return;

	applyModels( data, params.minResolution, params.applyTo, modelLinks );

	// now save it
	SpimData2.saveXML( result.getData(), result.getXMLFileName(), result.getClusterExtension() );

}
 
Example #27
Source File: PairwiseStitching.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static <T extends RealType< T >, C extends Comparable< C >> List< PairwiseStitchingResult< C > > getPairwiseShiftsLucasKanade(
		final Map< C, RandomAccessibleInterval< T > > rais, final Map< C, TranslationGet > translations,
		final LucasKanadeParameters params, final ExecutorService service)
{
	List< C > indexes = new ArrayList< >( rais.keySet() );
	Collections.sort( indexes );

	List< PairwiseStitchingResult< C > > result = new ArrayList< >();

	// got through all pairs with index1 < index2
	for ( int i = 0; i < indexes.size(); i++ )
	{
		for ( int j = i + 1; j < indexes.size(); j++ )
		{
			Pair< AffineTransform, Double > resT = getShiftLucasKanade( rais.get( indexes.get( i ) ), rais.get( indexes.get( j ) ),
					translations.get( indexes.get( i ) ), translations.get( indexes.get( j ) ), params, service );

			if ( resT != null )
			{
				Set<C> setA = new HashSet<>();
				setA.add( indexes.get( i ) );
				Set<C> setB = new HashSet<>();
				setA.add( indexes.get( j ) );
				Pair< Group<C>, Group<C> > key = new ValuePair<>(new Group<>(setA), new Group<>(setB));
				result.add( new PairwiseStitchingResult< C >( key, null, resT.getA() , resT.getB(), 0.0 ) );
			}
			
		}
	}

	return result;
}
 
Example #28
Source File: DemoLinkOverlay.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static boolean overlapsWith( final Pair<Group<ViewId>, Group<ViewId>> p1, final Collection< Pair<Group<ViewId>, Group<ViewId>>> pairList )
{
	for ( final Pair<Group<ViewId>, Group<ViewId>> p2 : pairList )
		if ( overlapsWith( p1, p2 ) )
			return true;

	return false;
}
 
Example #29
Source File: GeomNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.geom.geom2d.DefaultMinimumFeret.class)
public Pair<RealLocalizable, RealLocalizable> minimumFeret(final Polygon2D in) {
	@SuppressWarnings("unchecked")
	final Pair<RealLocalizable, RealLocalizable> result =
		(Pair<RealLocalizable, RealLocalizable>) ops().run(net.imagej.ops.geom.geom2d.DefaultMinimumFeret.class, in);
	return result;
}
 
Example #30
Source File: NormalizeScaleRealTypes.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void checkInput(final IterableInterval<I> in) {
	final Pair<I, I> minMax = minMaxFunc.calculate(in);
	factor = (minMax.getB().getRealDouble() - minMax.getA()
		.getRealDouble()) / (outMax - outMin);

	inMin = minMax.getA().getRealDouble();
}