本文整理汇总了Java中net.imglib2.RealInterval类的典型用法代码示例。如果您正苦于以下问题:Java RealInterval类的具体用法?Java RealInterval怎么用?Java RealInterval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealInterval类属于net.imglib2包,在下文中一共展示了RealInterval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTranslation
import net.imglib2.RealInterval; //导入依赖的package包/类
public static FinalRealInterval applyTranslation(RealInterval img, TranslationGet translation, boolean[] ignoreDims){
// get number of dimensions we actually use
int n = 0;
for (int d = 0; d < ignoreDims.length; ++d)
if (!ignoreDims[d])
n++;
final double [] min = new double [n];
final double [] max = new double [n];
int i2 = 0;
for (int i = 0; i< img.numDimensions();++i)
{
if (!ignoreDims[i])
{
min[i2] = img.realMin(i) + translation.getTranslation(i);
max[i2] = img.realMax(i) + translation.getTranslation(i);
i2++;
}
}
return new FinalRealInterval(min, max);
}
示例2: getLocalRasterOverlap
import net.imglib2.RealInterval; //导入依赖的package包/类
/**
* create an integer interval from real interval, being conservatie on the size
* (min is ceiled, max is floored)
* @param overlap real input
* @return interger interval, with mins ceiled and maxs floored
*/
public static FinalInterval getLocalRasterOverlap(RealInterval overlap)
{
final int n = overlap.numDimensions();
final long [] min = new long [n];
final long [] max = new long [n];
for (int i = 0; i< n; i++)
{
// round down errors when it is exactly 0.5, if we do not do this we end up with two intervals
// of different size, e.g.:
// if the first interval starts at 139.5 going to 199, the second one at 0.0 going to 59.5
// then the rastered 1st would go from round(139.5)=140 + 1 = 141 -to- round(199)=199 - 1 = 198, dim=58
// and the rastered 2nd would go from round(0.0)=0 + 1 = 1 -to- round(59.5)=60 - 1 = 59, dim=59
min[i] = Math.round((overlap.realMin(i) - 0.0001 )) + 1;
max[i] = Math.round((overlap.realMax(i) + 0.0001 )) - 1;
}
return new FinalInterval(min, max);
}
示例3: getOverlap
import net.imglib2.RealInterval; //导入依赖的package包/类
public static FinalRealInterval getOverlap(final RealInterval img1, final RealInterval img2){
final int n = img1.numDimensions();
final double [] min = new double [n];
final double [] max = new double [n];
for (int i = 0; i< n; i++)
{
min[i] = Math.max(img1.realMin(i), img2.realMin(i));
max[i] = Math.min(img1.realMax(i), img2.realMax(i));
// intervals do not overlap
if ( max[i] < min [i])
return null;
}
return new FinalRealInterval(min, max);
}
示例4: exec
import net.imglib2.RealInterval; //导入依赖的package包/类
public void exec( final String xmlHDF5Path, final int setupID, final String tgmmPath, final String outputPath, final boolean doCrop, final RealInterval interval, final int tFrom, final int tTo )
{
SpimDataMinimal spimData;
try
{
spimData = new XmlIoSpimDataMinimal().load( xmlHDF5Path );
}
catch ( final SpimDataException e )
{
logger.error( "Problem reading the transforms in image data file:\n" + e.getMessage() + "\n" );
return;
}
final Model model = createModel( new File( tgmmPath ), spimData, setupID, interval, tFrom, tTo );
model.setLogger( logger );
final Settings settings = createSettings( new File( xmlHDF5Path ) );
final TrackMate trackmate = new TrackMate( model, settings );
trackmate.setNumThreads( 1 );
trackmate.computeSpotFeatures( true );
trackmate.computeEdgeFeatures( true );
trackmate.computeTrackFeatures( true );
save( outputPath, model, settings );
}
示例5: launchMamut
import net.imglib2.RealInterval; //导入依赖的package包/类
public void launchMamut( final File imageFile, final File tgmmFile, final int setupID, final RealInterval interval )
{
SpimDataMinimal spimData;
try
{
spimData = new XmlIoSpimDataMinimal().load( imageFile.getAbsolutePath() );
}
catch ( final SpimDataException e )
{
logger.error( "Problem reading the transforms in image data file:\n" + e.getMessage() + "\n" );
return;
}
final Model model = createModel( tgmmFile, spimData, setupID, interval );
final SourceSettings settings = createSettings();
new MaMuT( imageFile, model, settings );
}
示例6: createModel
import net.imglib2.RealInterval; //导入依赖的package包/类
protected Model createModel( final File tgmmFolder, final SpimDataMinimal spimData, final int setupID, final RealInterval interval )
{
final List< AffineTransform3D > transforms = pickTransform( spimData, setupID );
final TGMMImporter2 importer = new TGMMImporter2( tgmmFolder, transforms, TGMMImporter2.DEFAULT_PATTERN, logger, interval, 0, Integer.MAX_VALUE );
if ( !importer.checkInput() || !importer.process() )
{
logger.error( importer.getErrorMessage() );
return new Model();
}
final Model model = importer.getResult();
/*
* Hack to set the POSITION_T feature of imported spots.
*/
final Settings settings = new Settings();
settings.dt = 1;
final TrackMate trackmate = new TrackMate( model, settings );
final ResetSpotTimeFeatureAction action = new ResetSpotTimeFeatureAction();
action.execute( trackmate );
return model;
}
示例7: getLocalOverlap
import net.imglib2.RealInterval; //导入依赖的package包/类
/**
* get overlap in local image coordinates (assuming min = (0,0,..))
* @param img image interval (global coordinates)
* @param overlap overlap interval (global coordinates)
* @return overlap interval in local coordinates
*/
public static FinalRealInterval getLocalOverlap(RealInterval img, RealInterval overlap){
final int n = img.numDimensions();
final double [] min = new double [n];
final double [] max = new double [n];
for (int i = 0; i< n; i++)
{
min[i] = Math.max(0, overlap.realMin(i) - img.realMin(i)) ;
max[i] = Math.max(0, overlap.realMax(i) - img.realMin(i));
}
return new FinalRealInterval(min, max);
}
示例8: flatIterable
import net.imglib2.RealInterval; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static final <T extends RealType<T>> IterableRealInterval<T> flatIterable(final RealInterval ri) {
// If it's any of the known classes that iterates flat, accept as is:
if ( ArrayImg.class.isInstance( ri )
|| ListImg.class.isInstance( ri )
|| IterableRandomAccessibleInterval.class.isInstance(ri)) {
return (IterableRealInterval<T>) ri;
}
// If it's a random accessible, then wrap:
if ( ri instanceof RandomAccessibleInterval ) {
return new IterableRandomAccessibleInterval<T>((RandomAccessibleInterval<T>)ri);
}
throw new IllegalArgumentException("Don't know how to flat-iterate image " + ri);
}
示例9: Dimensions
import net.imglib2.RealInterval; //导入依赖的package包/类
/**
* Extract the dimensions of {@param img} multiplied by the {@param factor}.
* @param img The interval to extract the dimensions of.
* @param factor The factor to multiply the dimensions.
*/
@SuppressWarnings("boxing")
public Dimensions(final RealInterval img, final Number factor) {
for (int i=0; i<img.numDimensions(); ++i) {
add((long)((img.realMax(i) - img.realMin(i) + 1) * factor.doubleValue()));
}
}
示例10: createModel
import net.imglib2.RealInterval; //导入依赖的package包/类
protected Model createModel( final File tgmmFolder, final SpimDataMinimal spimData, final int setupID, final RealInterval interval, final int tFrom, final int tTo )
{
final SequenceDescriptionMinimal seq = spimData.getSequenceDescription();
final ViewRegistrations regs = spimData.getViewRegistrations();
final List< AffineTransform3D > transforms = new ArrayList< AffineTransform3D >( seq.getTimePoints().size() );
for ( final TimePoint t : seq.getTimePoints().getTimePointsOrdered() )
{
transforms.add( regs.getViewRegistration( t.getId(), setupID ).getModel() );
}
final TGMMImporter2 importer = new TGMMImporter2( tgmmFolder, transforms, TGMMImporter2.DEFAULT_PATTERN, logger, interval, tFrom, tTo );
if ( !importer.checkInput() || !importer.process() )
{
logger.error( importer.getErrorMessage() );
}
final Model model = importer.getResult();
/*
* Hack to set the POSITION_T feature of imported spots.
*/
final Settings settings = new Settings();
settings.dt = 1;
final TrackMate trackmate = new TrackMate( model, settings );
final ResetSpotTimeFeatureAction action = new ResetSpotTimeFeatureAction();
action.execute( trackmate );
return model;
}
示例11: TGMMImporter2
import net.imglib2.RealInterval; //导入依赖的package包/类
public TGMMImporter2( final File file, final List< AffineTransform3D > transforms, final Pattern framePattern, final Logger logger, final RealInterval interval, final int tFrom, final int tTo )
{
this.file = file;
this.framePattern = framePattern;
this.transforms = transforms;
this.logger = logger;
this.interval = interval;
this.tFrom = tFrom;
this.tTo = tTo;
}
示例12: realRandomAccess
import net.imglib2.RealInterval; //导入依赖的package包/类
@Override
public RealRandomAccess<FloatType> realRandomAccess( final RealInterval interval )
{
return Views.interpolate(
Views.extendZero( this.contentBasedImg ),
new NLinearInterpolatorFactory< FloatType >()
).realRandomAccess( interval );
}
示例13: main
import net.imglib2.RealInterval; //导入依赖的package包/类
public static void main(String[] args)
{
RandomAccessibleInterval< FloatType > a = ImgLib2Util.openAs32Bit( new File( "73.tif.zip" ) );
RandomAccessibleInterval< FloatType > b = ImgLib2Util.openAs32Bit( new File( "74.tif.zip" ) );
long slice = 40;
ImageJFunctions.show( a );
a = Views.zeroMin( Views.hyperSlice( a, 2, slice ));
b = Views.zeroMin( Views.hyperSlice( b, 2, slice ));
TranslationGet t1 = new Translation2D();
TranslationGet t2 = new Translation2D(460, 0);
ArrayList< Pair< RealInterval, AffineGet > > views = new ArrayList<Pair<RealInterval, AffineGet>>();
views.add( new ValuePair< RealInterval, AffineGet >( a, t1 ) );
views.add( new ValuePair< RealInterval, AffineGet >( b, t2 ) );
RealInterval overlap = BoundingBoxMaximalGroupOverlap.getMinBoundingIntervalSingle( views );
final RealInterval transformed1 = TransformTools.applyTranslation( a, t1, new boolean[] {false, false} );
final RealInterval transformed2 = TransformTools.applyTranslation( b, t2, new boolean[] {false, false} );
// get overlap in images' coordinates
final RealInterval localOverlap1 = TransformTools.getLocalOverlap( transformed1, overlap );
final RealInterval localOverlap2 = TransformTools.getLocalOverlap( transformed2, overlap );
// round to integer interval
final Interval interval1 = TransformTools.getLocalRasterOverlap( localOverlap1 );
final Interval interval2 = TransformTools.getLocalRasterOverlap( localOverlap2 );
//final WarpFunction warp = new TranslationWarp(3);
final WarpFunction warp = new RigidWarp(2);
//final WarpFunction warp = new AffineWarp( 3 );
// rotate second image
AffineTransform2D rot = new AffineTransform2D();
rot.rotate( 1.4 * Math.PI / 180 );
RandomAccessibleInterval< FloatType > rotated = Views.interval(
RealViews.affine(
Views.interpolate( Views.extendMirrorSingle( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
rot.copy() ),
interval2);
// show input
new ImageJ();
ImageJFunctions.show( Views.interval( a, interval1 ) );
ImageJFunctions.show( rotated );
// downsample input
RandomAccessibleInterval< FloatType > simple2x1 = Downsample.simple2x( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), new boolean[] {false, false} );
RandomAccessibleInterval< FloatType > simple2x2 = Downsample.simple2x( Views.zeroMin( Views.interval( rotated, interval2 ) ), new ArrayImgFactory<>(), new boolean[] {false, false} );
// align
//Align< FloatType > lk = new Align<>( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), warp );
Align< FloatType > lk = new Align<>( simple2x1, new ArrayImgFactory<>(), warp );
//System.out.println( Util.printCoordinates( lk.align( Views.zeroMin( Views.interval( b, interval2 ) ), 100, 0.01 ).getRowPackedCopy() ) );
//final AffineTransform transform = lk.align( Views.zeroMin( rotated ), 100, 0.01 );
final AffineTransform transform = lk.align( simple2x2, 100, 0.1 );
// transformation matrix
System.out.println( Util.printCoordinates( transform.getRowPackedCopy() ) );
// correct input and show
RandomAccessibleInterval< FloatType > backRotated = Views.interval(
RealViews.affine(
Views.interpolate( Views.extendMirrorSingle( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
rot.copy().preConcatenate( transform ).copy() ),
interval2);
ImageJFunctions.show( backRotated );
// constructor needs column packed matrix, therefore the transpose
Matrix mt = new Matrix( transform.getRowPackedCopy(), 3).transpose();
Matrix rigid = mt.getMatrix( 0, 1, 0, 1 );
// check whether result is rotation matrix (det == +-1, orthogonal)
System.out.println( rigid.det() );
System.out.println( Util.printCoordinates( rigid.times( rigid.transpose() ).getRowPackedCopy() ) );
}
示例14: main
import net.imglib2.RealInterval; //导入依赖的package包/类
public static void main(String[] args)
{
Img< FloatType > a = ImgLib2Util.openAs32Bit( new File( "73.tif.zip" ) );
Img< FloatType > b = ImgLib2Util.openAs32Bit( new File( "74.tif.zip" ) );
TranslationGet t1 = new Translation3D();
TranslationGet t2 = new Translation3D(460, 0, 0);
ArrayList< Pair< RealInterval, AffineGet > > views = new ArrayList<Pair<RealInterval, AffineGet>>();
views.add( new ValuePair< RealInterval, AffineGet >( a, t1 ) );
views.add( new ValuePair< RealInterval, AffineGet >( b, t2 ) );
RealInterval overlap = BoundingBoxMaximalGroupOverlap.getMinBoundingIntervalSingle( views );
final RealInterval transformed1 = TransformTools.applyTranslation( a, t1, new boolean[] {false, false, false} );
final RealInterval transformed2 = TransformTools.applyTranslation( b, t2, new boolean[] {false, false, false} );
// get overlap in images' coordinates
final RealInterval localOverlap1 = TransformTools.getLocalOverlap( transformed1, overlap );
final RealInterval localOverlap2 = TransformTools.getLocalOverlap( transformed2, overlap );
// round to integer interval
final Interval interval1 = TransformTools.getLocalRasterOverlap( localOverlap1 );
final Interval interval2 = TransformTools.getLocalRasterOverlap( localOverlap2 );
//final WarpFunction warp = new TranslationWarp(3);
final WarpFunction warp = new RigidWarp(3);
//final WarpFunction warp = new AffineWarp( 3 );
// rotate second image
AffineTransform3D rot = new AffineTransform3D();
rot.rotate( 2, 2 * Math.PI / 180 );
RandomAccessibleInterval< FloatType > rotated = Views.interval(
RealViews.affine(
Views.interpolate( Views.extendBorder( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
rot.copy() ),
interval2);
// show input
new ImageJ();
ImageJFunctions.show( Views.interval( a, interval1 ), "target" );
ImageJFunctions.show( rotated, "in");
// downsample input
RandomAccessibleInterval< FloatType > simple2x1 = Downsample.simple2x( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), new boolean[] {true, true, false} );
RandomAccessibleInterval< FloatType > simple2x2 = Downsample.simple2x( Views.zeroMin( Views.interval( rotated, interval2 ) ), new ArrayImgFactory<>(), new boolean[] {true, true, false} );
// align
//Align< FloatType > lk = new Align<>( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), warp );
Align< FloatType > lk = new Align<>( simple2x1, new ArrayImgFactory<>(), warp );
//System.out.println( Util.printCoordinates( lk.align( Views.zeroMin( Views.interval( b, interval2 ) ), 100, 0.01 ).getRowPackedCopy() ) );
//final AffineTransform transform = lk.align( Views.zeroMin( rotated ), 100, 0.01 );
final AffineTransform transform = lk.align( simple2x2, 100, 0.01 );
final AffineTransform scale = new AffineTransform( 3 );
scale.set( 2, 0, 0 );
scale.set( 1, 1, 1 );
transform.preConcatenate( scale );
// transformation matrix
System.out.println( Util.printCoordinates( transform.getRowPackedCopy() ) );
// correct input and show
RandomAccessibleInterval< FloatType > backRotated = Views.interval(
RealViews.affine(
Views.interpolate( Views.extendBorder( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
rot.copy().preConcatenate( transform ).copy() ),
interval2);
ImageJFunctions.show( backRotated, "out" );
// constructor needs column packed matrix, therefore the transpose
Matrix mt = new Matrix( transform.getRowPackedCopy(), 4).transpose();
Matrix rigid = mt.getMatrix( 0, 2, 0, 2 );
// check whether result is rotation matrix (det == +-1, orthogonal)
System.out.println( rigid.det() );
System.out.println( Util.printCoordinates( rigid.times( rigid.transpose() ).getRowPackedCopy() ) );
}
示例15: printRealInterval
import net.imglib2.RealInterval; //导入依赖的package包/类
public static String printRealInterval( final RealInterval interval )
{
String out = "(Interval empty)";
if ( interval == null || interval.numDimensions() == 0 )
return out;
out = "[" + interval.realMin( 0 );
for ( int i = 1; i < interval.numDimensions(); i++ )
out += ", " + interval.realMin( i );
out += "] -> [" + interval.realMax( 0 );
for ( int i = 1; i < interval.numDimensions(); i++ )
out += ", " + interval.realMax( i );
out += "]";
return out;
}