Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Oct 17, 2024
1 parent 7e88fc7 commit d83d3ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/embl/mobie/lib/image/StitchedImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
package org.embl.mobie.lib.image;

import static net.imglib2.view.fluent.RandomAccessibleIntervalView.Extension.value;
import static net.imglib2.view.fluent.RandomAccessibleView.Interpolation.nearestNeighbor;

import bdv.tools.transformation.TransformedSource;
import bdv.util.Affine3DHelpers;
import bdv.util.DefaultInterpolators;
Expand All @@ -42,7 +45,6 @@
import net.imglib2.RealPoint;
import net.imglib2.RealRandomAccessible;
import net.imglib2.Volatile;
import net.imglib2.interpolation.randomaccess.NearestNeighborInterpolatorFactory;
import net.imglib2.outofbounds.OutOfBoundsConstantValueFactory;
import net.imglib2.position.FunctionRandomAccessible;
import net.imglib2.realtransform.AffineTransform3D;
Expand All @@ -54,6 +56,7 @@
import net.imglib2.view.ExtendedRandomAccessibleInterval;
import net.imglib2.view.IntervalView;
import net.imglib2.view.Views;

import org.embl.mobie.DataStore;
import org.embl.mobie.lib.MoBIEHelper;
import org.embl.mobie.lib.ThreadHelper;
Expand Down Expand Up @@ -392,7 +395,7 @@ static class StitchedSource< T extends Type< T > > implements Source< T >
private final VoxelDimensions voxelDimensions;
private final T type;
private final String name;
private final DefaultInterpolators< ? extends NumericType > interpolators;
private final DefaultInterpolators interpolators;

public StitchedSource(
final Map< Integer, List< RandomAccessibleInterval< T > > > stitched,
Expand Down Expand Up @@ -455,9 +458,9 @@ public RealRandomAccessible< T > getInterpolatedSource( int t, int level, Interp
}
else
{
final T outOfBoundsVariable = type.createVariable();
final RandomAccessible ra = new ExtendedRandomAccessibleInterval<>( getSource( t, level ), new OutOfBoundsConstantValueFactory<>( outOfBoundsVariable ) );
return Views.interpolate( ra, new NearestNeighborInterpolatorFactory< T >() );
return getSource( t, level ).view()
.extend( value( type.createVariable() ) )
.interpolate( nearestNeighbor() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public WithinDistancesSearchOnKDTree( final KDTree< T > tree )
this.tree = tree;
this.n = tree.numDimensions();
this.pos = new float[ n ];
this.resultPoints = new ArrayList< ValuePair< KDTreeNode< T >, Double > >();
this.resultPoints = new ArrayList<>();
}

public void search( final RealLocalizable reference, final double[] distances, final boolean sortResults )
Expand Down Expand Up @@ -93,20 +93,33 @@ protected void searchNode( final KDTreeNode< T > current, final double[] distanc
}
}

Double distance = Double.valueOf( 0 ); // TODO: If we want round dots and if we want to sort
// TODO: If we want round dots and if we want to sort

if ( closeEnough )
{
resultPoints.add( new ValuePair< KDTreeNode< T >, Double >( current, distance ) );
resultPoints.add( new ValuePair<>( current, 0.0 ) );
}

final double axisDiff = pos[ current.getSplitDimension() ] - current.getSplitCoordinate();
final boolean leftIsNearBranch = axisDiff < 0;
final double axisAbsDistance = Math.abs( axisDiff );

// search the near branch
final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left : current.right;
final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right : current.left;
final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left() : current.right();
final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right() : current.left();

// TODO: Revise for efficiency:
// current.left() and current.right() are deprecated.
// They will create new KDTreeNode instances everytime.
// Searches on the KDTree are now implemented on net.imglib2.kdtree.KDTreeImpl (which has the tree structure but no associated values).
// See for example net.imglib2.kdtree.RadiusNeighborSearchImpl
// https://github.com/imglib/imglib2/blob/e6545cc41cabdcd16aba5f655fe9f92b9789797a/src/main/java/net/imglib2/kdtree/RadiusNeighborSearchImpl.java#L46
// This is then wrapped to present the results as KDTreeNodes.
// See for example net.imglib2.neighborsearch.RadiusNeighborSearchOnKDTree
// https://github.com/imglib/imglib2/blob/e6545cc41cabdcd16aba5f655fe9f92b9789797a/src/main/java/net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree.java#L50
// WithinDistancesSearchOnKDTree seems to be a slightly modified RadiusNeighborSearchOnKDTree?
// So it should be relatively easy to adapt.

if ( nearChild != null )
searchNode( nearChild, distances );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
package org.embl.mobie.lib.source;

import static net.imglib2.view.fluent.RandomAccessibleIntervalView.Extension.value;
import static net.imglib2.view.fluent.RandomAccessibleView.Interpolation.nearestNeighbor;

import bdv.util.DefaultInterpolators;
import bdv.viewer.Interpolation;
import bdv.viewer.Source;
Expand All @@ -52,7 +55,7 @@ public class RandomAccessibleIntervalMipmapSource< T extends Type< T > > impleme
private final VoxelDimensions voxelDimensions;
private final T type;
private final String name;
private final DefaultInterpolators< ? extends NumericType > interpolators;
private final DefaultInterpolators interpolators;

public RandomAccessibleIntervalMipmapSource(
final List< RandomAccessibleInterval< T > > rais,
Expand Down Expand Up @@ -118,9 +121,9 @@ public RealRandomAccessible< T > getInterpolatedSource( int t, int level, Interp
}
else
{
final T outOfBoundsVariable = type.createVariable();
final RandomAccessible ra = new ExtendedRandomAccessibleInterval<>( getSource( t, level ), new OutOfBoundsConstantValueFactory<>( outOfBoundsVariable ) );
return Views.interpolate( ra, new NearestNeighborInterpolatorFactory< T >() );
return getSource( t, level ).view()
.extend( value( type.createVariable() ) )
.interpolate( nearestNeighbor() );
}
}

Expand Down

0 comments on commit d83d3ae

Please sign in to comment.