本文整理汇总了Java中net.imglib2.util.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于net.imglib2.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.imglib2.util.Util; //导入依赖的package包/类
public static void main( String[] args )
{
SpimData spimData = grid3x2();
SequenceDescription sd = spimData.getSequenceDescription();
ImgLoader i = sd.getImgLoader();
TimePoint firstTp = sd.getTimePoints().getTimePointsOrdered().get( 0 );
int tpId = firstTp.getId();
for ( final ViewSetup vs: spimData.getSequenceDescription().getViewSetups().values() )
{
SetupImgLoader< ? > sil = i.getSetupImgLoader( vs.getId() );
ViewDescription vd = sd.getViewDescription( tpId, vs.getId() );
Tile t = vd.getViewSetup().getTile();
if ( t.hasLocation() )
System.out.println( "Loading: " + t.getName() + " " + Util.printCoordinates( t.getLocation() ) + " " + vd.getViewSetup().getChannel().getName() );
else
System.out.println( "Loading: " + t.getName() + " (unknown location) " + vd.getViewSetup().getChannel().getName() );
ImageJFunctions.show( (RandomAccessibleInterval< UnsignedShortType >)sil.getImage( tpId, ImgLoaderHints.LOAD_COMPLETELY ) ).resetDisplayRange();
}
}
示例2: main
import net.imglib2.util.Util; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
System.out.println( "== Old style:" );
Map< Pair< File, Integer >, Translation3D > res = parseTileConfigurationOld(
new File( "/Users/david/Desktop/tileConfigOld.txt" ) );
if ( res != null )
res.entrySet().forEach( e -> {
System.out.println( e.getKey().getA() + ", series " + e.getKey().getB() + ": "
+ Util.printCoordinates( e.getValue().getTranslationCopy() ) );
} );
System.out.println( "== New style:" );
Map< ViewId, Translation3D > res2 = parseTileConfiguration(
new File( "/Users/david/Desktop/tileConfig.txt" ) );
if ( res2 != null )
res2.entrySet().forEach( e -> {
System.out.println( "View: " + e.getKey().getViewSetupId() + ", TP: " + e.getKey().getTimePointId()
+ ": " + Util.printCoordinates( e.getValue().getTranslationCopy() ) );
} );
}
示例3: readCellDimensions
import net.imglib2.util.Util; //导入依赖的package包/类
static private int[][] readCellDimensions(
final IHDF5Reader reader,
final IHDF5Reader scaleReader,
final String dataset,
final int[] cellDimension )
{
if ( scaleReader == null )
return new int[][] { cellDimension };
else
{
final int numMipmapLevels = scaleReader.uint32().read( "levels" );
final int[][] cellDimensions = new int[ numMipmapLevels ][];
cellDimensions[ 0 ] = cellDimension;
for ( int level = 1; level < numMipmapLevels; ++level )
{
final String blocksizePath = String.format( "l%02d/blocksize", level );
cellDimensions[ level ] = Util.long2int( scaleReader.uint64().readArray( blocksizePath ) );
}
return cellDimensions;
}
}
示例4: getIntIntImgLabellingFromLabelMapImagePlus
import net.imglib2.util.Util; //导入依赖的package包/类
public static ImgLabeling< Integer, IntType > getIntIntImgLabellingFromLabelMapImagePlus( final ImagePlus labelMap )
{
final Img< FloatType > img2 = ImageJFunctions.convertFloat( labelMap );
final Dimensions dims = img2;
final IntType t = new IntType();
final RandomAccessibleInterval< IntType > img = Util.getArrayOrCellImgFactory( dims, t ).create( dims, t );
final ImgLabeling< Integer, IntType > labeling = new ImgLabeling<>( img );
final Cursor< LabelingType< Integer > > labelCursor = Views.flatIterable( labeling ).cursor();
for ( final UnsignedByteType input : Views.flatIterable( ImageJFunctions.wrapByte( labelMap ) ) )
{
final LabelingType< Integer > element = labelCursor.next();
if ( input.get() != 0 )
element.add( input.get() );
}
return labeling;
}
示例5: colorLabels
import net.imglib2.util.Util; //导入依赖的package包/类
private static < C extends Type< C >, L > void colorLabels(
final ImgLabeling< L, ? > labeling,
final Iterator< C > colors,
final RandomAccessibleInterval< C > output )
{
final HashMap< Set< ? >, C > colorTable = new HashMap< Set< ? >, C >();
final LabelingMapping< ? > mapping = labeling.getMapping();
final int numLists = mapping.numSets();
final C color = Util.getTypeFromInterval( output ).createVariable();
colorTable.put( mapping.labelsAtIndex( 0 ), color );
for ( int i = 1; i < numLists; ++i )
{
final Set< ? > list = mapping.labelsAtIndex( i );
colorTable.put( list, colors.next() );
}
final Iterator< C > o = Views.flatIterable( output ).iterator();
for ( final C c : Converters.convert(
Views.flatIterable( labeling ),
new LabelingTypeConverter< C >( colorTable ),
color ) )
o.next().set( c );
}
示例6: initialize
import net.imglib2.util.Util; //导入依赖的package包/类
@Override
public void initialize() {
// the out of bounds factory will be different depending on wether we are
// using circulant or non-circulant
if (this.getOBFInput() == null) {
if (!nonCirculant) {
setOBFInput(new OutOfBoundsMirrorFactory<>(Boundary.SINGLE));
}
else if (nonCirculant) {
setOBFInput(new OutOfBoundsConstantValueFactory<>(Util
.getTypeFromInterval(in()).createVariable()));
}
}
computeEstimateOp = getComputeEstimateOp();
super.initialize();
}
示例7: addLeadingZeros
import net.imglib2.util.Util; //导入依赖的package包/类
/**
* Add 0s before axis minimum.
*
* @param input Input RAI
* @return An extended and cropped version of input
*/
private <T extends RealType<T>> RandomAccessibleInterval<T> addLeadingZeros(
RandomAccessibleInterval<T> input)
{
final long[] min = Intervals.minAsLongArray(input);
final long[] max = Intervals.maxAsLongArray(input);
for (int i = 0; i < max.length; i++) {
min[i]--;
}
final T realZero = Util.getTypeFromInterval(input).copy();
realZero.setZero();
final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extendedImg = Views.extendValue(input,
realZero);
final IntervalView<T> offsetInterval = Views.interval(extendedImg,
min, max);
return Views.zeroMin(offsetInterval);
}
示例8: initialize
import net.imglib2.util.Util; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize() {
maxVal = Util.getTypeFromInterval(in()).createVariable();
maxVal.setReal(maxVal.getMaxValue());
if (f == null) {
f = new OutOfBoundsConstantValueFactory<>(
maxVal);
}
final UnaryComputerOp neighborComputer = maxVal instanceof BitType
? new ErodeBitType() : Computers.unary(ops(), Ops.Stats.Min.class, maxVal
.createVariable(), Iterable.class);
imgCreator = (UnaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class,
Img.class, in(), maxVal.createVariable());
if (out() == null) setOutput(createOutput(in()));
mapper = ops().op(MapNeighborhood.class, out(), in1(), in2(),
neighborComputer);
}
示例9: initialize
import net.imglib2.util.Util; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize() {
maxVal = Util.getTypeFromInterval(in()).createVariable();
maxVal.setReal(maxVal.getMaxValue());
imgCreator = (UnaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class,
Img.class, in(), maxVal.createVariable());
copyImg = (UnaryComputerOp) Computers.unary(ops(),
Ops.Copy.IterableInterval.class, IterableInterval.class, Views.iterable(
in1()));
erodeComputer = (BinaryComputerOp) Computers.unary(ops(),
Ops.Morphology.Erode.class, IterableInterval.class, in1(), in2().get(0),
false);
}
示例10: initialize
import net.imglib2.util.Util; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize() {
minVal = Util.getTypeFromInterval(in()).createVariable();
minVal.setReal(minVal.getMinValue());
if (f == null) {
f = new OutOfBoundsConstantValueFactory<>(
minVal);
}
final UnaryComputerOp neighborComputer = minVal instanceof BitType
? new DilateBitType() : Computers.unary(ops(), Ops.Stats.Max.class, minVal
.createVariable(), Iterable.class);
imgCreator = (UnaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class,
Img.class, in(), minVal.createVariable());
if (out() == null) setOutput(createOutput(in()));
mapper = ops().op(MapNeighborhood.class, out(), in1(), in2(),
neighborComputer);
}
示例11: initialize
import net.imglib2.util.Util; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize() {
minVal = Util.getTypeFromInterval(in()).createVariable();
minVal.setReal(minVal.getMinValue());
imgCreator = (UnaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class,
Img.class, in(), minVal.createVariable());
copyImg = (UnaryComputerOp) Computers.unary(ops(),
Ops.Copy.IterableInterval.class, IterableInterval.class, Views.iterable(
in1()));
dilateComputer = (BinaryComputerOp) Computers.unary(ops(),
Ops.Morphology.Dilate.class, IterableInterval.class, in1(), in2().get(0),
false);
}
示例12: testVarianceFilter
import net.imglib2.util.Util; //导入依赖的package包/类
/**
* @see VarianceFilterOp
* @see DefaultVarianceFilter
*/
@Test
public void testVarianceFilter() {
ops.run(VarianceFilterOp.class, out, in, shape, oobFactory);
double sum = 0.0;
double sumSq = 0.0;
NeighborhoodsIterableInterval<ByteType> neighborhoods =
shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
sum += t.getRealDouble();
sumSq += t.getRealDouble()*t.getRealDouble();
}
assertEquals((byte)Util.round((sumSq - (sum * sum / 9)) / 8), out.firstElement().get());
}
示例13: mostPresentCal
import net.imglib2.util.Util; //导入依赖的package包/类
public static Cal mostPresentCal( final Collection< Cal > calibrations )
{
int max = 0;
Cal maxCal = null;
for ( final Cal cal : calibrations )
{
if ( cal.getCount() > max )
{
max = cal.getCount();
maxCal = cal;
}
}
IOFunctions.println( "Number of calibrations: " + calibrations.size() );
IOFunctions.println( "Calibration most often present: " + Util.printCoordinates( maxCal.getCal() ) + " (" + maxCal.getCount() + " times)" );
return maxCal;
}
示例14: median
import net.imglib2.util.Util; //导入依赖的package包/类
private static final double[] median( final List< InterestPoint > list )
{
final int n = list.get( 0 ).getL().length;
final double[][] values = new double[ n ][ list.size() ];
for ( int j = 0; j < list.size(); ++j )
{
final double[] l = list.get( j ).getL();
for ( int d = 0; d < n; ++d )
values[ d ][ j ] = l[ d ];
}
final double[] center = new double[ n ];
for ( int d = 0; d < n; ++d )
center[ d ] = Util.median( values[ d ] );
return center;
}
示例15: determineSizeSimple
import net.imglib2.util.Util; //导入依赖的package包/类
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 );
}