本文整理汇总了Java中net.imglib2.exception.ImgLibException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ImgLibException.printStackTrace方法的具体用法?Java ImgLibException.printStackTrace怎么用?Java ImgLibException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.exception.ImgLibException
的用法示例。
在下文中一共展示了ImgLibException.printStackTrace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
static public final void main(String[] args) {
try {
FloatImage fi = new FloatImage(new long[]{10, 10, 10});
Cursor<FloatType> c = fi.cursor();
while (c.hasNext()) {
c.next().set(1);
}
IntegralImage ig = new IntegralImage(fi);
RandomAccess<DoubleType> p = ig.randomAccess();
p.setPosition(new long[]{9, 9, 9});
System.out.println("Test integral image passed: " + ((10 * 10 * 10) == p.get().get()));
new ImageJ();
ImgLib.show(ig, "Integral Image");
} catch (ImgLibException e) {
e.printStackTrace();
}
}
示例2: copyToFloatImagePlus
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
/** Copy the contents from img to an ImagePlus; assumes containers are compatible. */
static public ImagePlus copyToFloatImagePlus(final Img<? extends RealType<?>> img, final String title) {
ImagePlusImgFactory<FloatType> factory = new ImagePlusImgFactory<FloatType>();
ImagePlusImg<FloatType, ?> iml = factory.create(img, new FloatType());
Cursor<FloatType> c1 = iml.cursor();
Cursor<? extends RealType<?>> c2 = img.cursor();
while (c1.hasNext()) {
c1.fwd();
c2.fwd();
c1.get().set(c2.get().getRealFloat());
}
try {
ImagePlus imp = iml.getImagePlus();
imp.setTitle(title);
return imp;
} catch (ImgLibException e) {
e.printStackTrace();
return null;
}
}
示例3: testIntegralHistogram2d
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
@Test
public <R extends IntegerType<R> & NativeType<R>> void testIntegralHistogram2d() {
// Create a 2d image with values 0-9 in every dimension, so bottom right is 81.
Img<UnsignedByteType> img =
new UnsignedByteType().createSuitableNativeImg(
new ArrayImgFactory<UnsignedByteType>(),
new long[]{10, 10});
long[] p = new long[2];
Cursor<UnsignedByteType> c = img.cursor();
while (c.hasNext()) {
c.fwd();
c.localize(p);
c.get().setInteger(p[0] * p[1]);
}
// Create integral histogram with 10 bins
LinearHistogram<UnsignedByteType> lh = new LinearHistogram<UnsignedByteType>(10, 2, new UnsignedByteType(0), new UnsignedByteType(81));
Img<R> ih = IntegralHistogram.create(img, lh);
new ImageJ();
try {
ImgLib.wrap((Img)ih, "histogram").show();
} catch (ImgLibException e) {
e.printStackTrace();
}
}
示例4: wrap
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static final Image< FloatType > wrap( final Img< net.imglib2.type.numeric.real.FloatType > i )
{
if ( i instanceof ImagePlusImg )
{
try
{
return ImageJFunctions.wrapFloat( ((ImagePlusImg) i).getImagePlus() );
}
catch (ImgLibException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
else
{
return ImgLib2.wrapFloatToImgLib1( i );
}
}
示例5: copyToImageStack
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
public static < T extends NumericType< T > & NativeType< T > > ImagePlus copyToImageStack( final RealRandomAccessible< T > rai, final Interval itvl )
{
final long[] dimensions = new long[ itvl.numDimensions() ];
itvl.dimensions( dimensions );
// create the image plus image
final T t = rai.realRandomAccess().get();
final ImagePlusImgFactory< T > factory = new ImagePlusImgFactory< T >();
final ImagePlusImg< T, ? > target = factory.create( itvl, t );
double k = 0;
final long N = dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ];
final net.imglib2.Cursor< T > c = target.cursor();
final RealRandomAccess< T > ra = rai.realRandomAccess();
while ( c.hasNext() )
{
c.fwd();
ra.setPosition( c );
c.get().set( ra.get() );
if ( k % 10000 == 0 )
{
IJ.showProgress( k / N );
}
k++;
}
IJ.showProgress( 1.1 );
try
{
return target.getImagePlus();
}
catch ( final ImgLibException e )
{
e.printStackTrace();
}
return null;
}
示例6: main
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
public static void main(String[] args) {
Img<UnsignedByteType> img = ImgLib.wrap(IJ.openImage("/home/albert/Desktop/t2/bridge.gif"));
Img<UnsignedByteType> multiPeriodic =
new ROI<UnsignedByteType>(
new ExtendPeriodic<UnsignedByteType>(img),
new long[]{-512, -512},
new long[]{1024, 1024});
Img<UnsignedByteType> multiMirroredDouble =
new ROI<UnsignedByteType>(
new ExtendMirrorDouble<UnsignedByteType>(img),
new long[]{-512, -512},
new long[]{1024, 1024});
Img<UnsignedByteType> multiMirroredSingle =
new ROI<UnsignedByteType>(
new ExtendMirrorSingle<UnsignedByteType>(img),
new long[]{-512, -512},
new long[]{1024, 1024});
Img<UnsignedByteType> centered =
new ROI<UnsignedByteType>(
new Extend<UnsignedByteType>(img, 0),
new long[]{-512, -512},
new long[]{1024, 1024});
// Above, notice the negative offsets. This needs fixing, it's likely due to recent change
// in how offsets are used. TODO
try {
ImgLib.show(multiPeriodic, "periodic");
ImgLib.show(multiMirroredDouble, "mirror double edge");
ImgLib.show(multiMirroredSingle, "mirror single edge");
ImgLib.show(centered, "translated 0 background");
} catch (ImgLibException e) {
e.printStackTrace();
}
}
示例7: ExampleIntegralImageFeatures
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
public ExampleIntegralImageFeatures() throws ImgIOException {
// Open an image
String src = "/home/albert/lab/TEM/abd/microvolumes/Seg/180-220-int/180-220-int-00.tif"; // 2d
final Img<UnsignedByteType> img = (Img<UnsignedByteType>) new ImgOpener().openImgs(src).get(0);
// Integral image
final Img<LongType> integralImg = new FastIntegralImg<UnsignedByteType, LongType>(img, new LongType(), new IdentityConverter<UnsignedByteType, LongType>());
// Integral image of squares
final Img<LongType> integralImgSq = new FastIntegralImg<UnsignedByteType, LongType>(img, new LongType(), new SquaringConverter<UnsignedByteType, LongType>());
// Size of the window
final long[] radius = new long[integralImg.numDimensions()];
for (int d=0; d<radius.length; ++d) radius[d] = 5;
// Cursors
final IntegralCursor<LongType> c1 = new IntegralCursor<LongType>(integralImg, radius);
final IntegralCursor<LongType> c2 = new IntegralCursor<LongType>(integralImgSq, radius);
// View features
final long NUM_FEATURES = 4;
final long[] dims = new long[integralImg.numDimensions() + 1];
for (int d = 0; d<dims.length -1; ++d) dims[d] = integralImg.dimension(d);
dims[dims.length -1] = NUM_FEATURES;
final Img<FloatType> featureStack = new FloatType().createSuitableNativeImg(
new ArrayImgFactory<FloatType>(), dims);
final RandomAccess<FloatType> cf = featureStack.randomAccess();
while (c1.hasNext()) {
final Pair<LongType, long[]> sum = c1.next();
final Pair<LongType, long[]> sumSq = c2.next();
cf.setPosition(c1);
// 1. The sum
cf.setPosition(0, dims.length -1);
cf.get().set(sum.getA().getRealFloat());
// 2. The sum of squares
cf.fwd(dims.length -1);
cf.get().set(sumSq.getA().getRealFloat());
// 3. The mean
cf.fwd(dims.length -1);
cf.get().set(sum.getA().getRealFloat() / sum.getB()[0]);
// 4. The stdDev
cf.fwd(dims.length -1);
cf.get().set((float)((sumSq.getA().getRealFloat() - (Math.pow(sum.getA().getRealFloat(), 2) / sum.getB()[0])) / sum.getB()[0]));
}
try {
new ImageJ();
ImgLib.wrap(featureStack).show();
} catch (ImgLibException e) {
e.printStackTrace();
}
}
示例8: testIntegralHistogram1d
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
@Test
public <R extends IntegerType<R> & NativeType<R>> void testIntegralHistogram1d() {
// Create a 1d image with values 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7
Img<UnsignedByteType> img =
new UnsignedByteType().createSuitableNativeImg(
new ArrayImgFactory<UnsignedByteType>(), new long[]{16});
Cursor<UnsignedByteType> c = img.cursor();
int i = 0;
int next = 0;
while (c.hasNext()) {
c.fwd();
c.get().set(next);
++i;
if (0 == i % 2) ++next;
}
//
LinearHistogram<UnsignedByteType> lh = new LinearHistogram<UnsignedByteType>(16, 1, new UnsignedByteType(0), new UnsignedByteType(7));
Img<R> ih = IntegralHistogram.create(img, lh);
new ImageJ();
try {
ImgLib.wrap((Img)ih, "histogram").show();
} catch (ImgLibException e) {
e.printStackTrace();
}
RandomAccess<R> ra = ih.randomAccess();
long[] position = new long[2];
StringBuilder sb = new StringBuilder();
for (int k=0; k<ih.dimension(0); ++k) {
position[0] = k;
sb.append(k + " :: {");
for (int h=0; h<ih.dimension(1); ++h) {
position[1] = h;
ra.setPosition(position);
System.out.println(ra.get().getRealDouble());
sb.append(h).append(':').append((long)ra.get().getRealDouble()).append("; ");
}
sb.append("}\n");
}
System.out.println(sb.toString());
}
示例9: main
import net.imglib2.exception.ImgLibException; //导入方法依赖的package包/类
final static public void main( final String[] args )
{
long t;
// final int[] samples = new int[ m ];
// final double[][] coordinates = new double[ m ][ 2 ];
// createPhyllotaxis1( samples, coordinates, size[ 0 ] / 2.0, size[ 1 ] / 2.0, 0.1 );
// createPattern2( samples, coordinates, size[ 0 ] / 2.0, size[ 1 ] / 2.0, 20 );
// final RealPointSampleList< UnsignedShortType > list = new RealPointSampleList< UnsignedShortType >( 2 );
// for ( int i = 0; i < samples.length; ++i )
// list.add( new RealPoint( coordinates[ i ] ), new UnsignedShortType( samples[ i ] ) );
final RealPointSampleList< UnsignedShortType > list = new RealPointSampleList< UnsignedShortType >( 3 );
createPhyllotaxis2( list, m, size[ 0 ] / 2.0, size[ 1 ] / 2.0, 20 );
final ImagePlusImgFactory< UnsignedShortType > factory = new ImagePlusImgFactory< UnsignedShortType >();
final KDTree< UnsignedShortType > kdtree = new KDTree< UnsignedShortType >( list );
new ImageJ();
IJ.log( "KDTree Search" );
IJ.log( "=============" );
/* nearest neighbor */
IJ.log( "Nearest neighbor ..." );
final ImagePlusImg< UnsignedShortType, ? > img4 = factory.create( new long[]{ size[ 0 ], size[ 1 ], 2 }, new UnsignedShortType() );
t = drawNearestNeighbor(
img4,
new NearestNeighborSearchOnKDTree< UnsignedShortType >( kdtree ) );
IJ.log( t + "ms " );
try
{
final ImagePlus imp4 = img4.getImagePlus();
imp4.setOpenAsHyperStack( true );
final CompositeImage impComposite = new CompositeImage( imp4, CompositeImage.COMPOSITE );
impComposite.show();
impComposite.setSlice( 1 );
IJ.run( impComposite, "Grays", "" );
impComposite.setDisplayRange( 0, m - 1 );
impComposite.setSlice( 2 );
impComposite.setDisplayRange( 0, 2 );
impComposite.updateAndDraw();
IJ.log( "Done." );
}
catch ( final ImgLibException e )
{
IJ.log( "Didn't work out." );
e.printStackTrace();
}
}