本文整理汇总了Java中net.imglib2.view.Views.translate方法的典型用法代码示例。如果您正苦于以下问题:Java Views.translate方法的具体用法?Java Views.translate怎么用?Java Views.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.view.Views
的用法示例。
在下文中一共展示了Views.translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> in1, final Shape in2,
final IterableInterval<T> output)
{
final RandomAccessibleInterval<T> extended = RAIs.extend(in1, f);
final RandomAccessibleInterval<T> shifted;
if (isFull) {
final long[] offset = MorphologyUtils
.computeTargetImageDimensionsAndOffset(in1, in2)[1];
shifted = Views.translate(extended, offset);
}
else {
shifted = extended;
}
mapper.compute(Views.interval(shifted, output), in2, output);
}
示例2: compute
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> in1, final Shape in2,
final IterableInterval<T> output)
{
final RandomAccessibleInterval<T> extended = RAIs.extend(in1, f);
final RandomAccessibleInterval<T> shifted;
if (isFull) {
final long[] offset = MorphologyUtils
.computeTargetImageDimensionsAndOffset(in1, in2)[1];
shifted = Views.translate(extended, offset);
}
else {
shifted = extended;
}
mapper.compute(Views.interval(shifted, output), in2, output);
}
示例3: testIntervalTranslate
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Test
public void testIntervalTranslate() {
Img<DoubleType> img = ArrayImgs.doubles(10,10);
IntervalView<DoubleType> expected = Views.translate(img, 2, 5);
IntervalView<DoubleType> actual = ops.transform().translateView(img, 2, 5);
for (int i = 0; i < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) actual.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
assertTrue(Intervals.equals(expected, actual));
}
示例4: createStore
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval< U > createStore( long[] min, long[] max, U u )
{
final long[] dimensions = new long[ min.length ];
for ( int d = 0; d < min.length; ++d )
dimensions[ d ] = max[ d ] - min[ d ] + 1;
ArrayImg< U, ? > imgFac = new ArrayImgFactory< U >().create( dimensions, u );
for ( U i : imgFac )
i.set( initialValue );
return Views.translate( imgFac, min );
}
示例5: show
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void show( final String[] args ) throws ImgIOException
{
ImageJ.main( args );
final File file = new File( "/Users/tinevez/Desktop/iconas/Data/Uneven.tif" );
final SCIFIOImgPlus img = new ImgOpener().openImgs( file.getAbsolutePath() ).get( 0 );
final Shape strel = new HyperSphereShape( 5 );
/*
* To new Img
*/
ImageJFunctions.show( img, "Source" );
final Img topHat = TopHat.topHat( img, strel, 1 );
ImageJFunctions.show( topHat, "WhiteTopHatToNewImg" );
/*
* In place
*/
final Interval interval = FinalInterval.createMinSize( new long[] { 30, 50, 88, 32 } );
final Img copy = img.copy();
TopHat.topHatInPlace( copy, interval, strel, 1 );
ImageJFunctions.show( copy, "WhiteTopHatInPlace" );
/*
* To target
*/
final Img img2 = img.factory().create( interval, new UnsignedByteType() );
final long[] translation = new long[ interval.numDimensions() ];
interval.min( translation );
final IntervalView translate = Views.translate( img2, translation );
TopHat.topHat( img, translate, strel, 1 );
ImageJFunctions.show( img2, "WhiteTopHatToTarget" );
}
示例6: defaultTranslateTest
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Test
public void defaultTranslateTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
MixedTransformView<DoubleType> il2 = Views.translate( deinterval(img), 2, 5);
MixedTransformView<DoubleType> opr = ops.transform().translateView( deinterval(img), 2, 5);
for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
}
示例7: main
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void main( String[] args )
{
final long[] dim = new long[] { 2, 3 };
long[] m = new long[ dim.length ];
long[] M = new long[ dim.length ];
ArrayImg< IntType, IntArray > img = ArrayImgs.ints( dim );
int i = 0;
for ( IntType c : img )
c.set( i++ );
Factory< IntType > factory = ( min1, max1, t1 ) -> {
final long[] dimensions1 = new long[ min1.length ];
for ( int d = 0; d < min1.length; ++d )
dimensions1[ d ] = max1[ d ] - min1[ d ] + 1;
ArrayImg< IntType, IntArray > imgFac = ArrayImgs.ints( dimensions1 );
return Views.translate( imgFac, min1 );
};
Function< long[], long[] > l = ( long[] array ) -> {
long[] result = array.clone();
for ( int k = 0; k < result.length; ++k )
result[ k ] = -result[ k ];
return result;
};
GrowingStoreRandomAccessible< IntType > rra = new GrowingStoreRandomAccessible<>( img, factory );
new ImageJ();
RandomAccess< IntType > ra = rra.randomAccess();
// Bdv bdv = BdvFunctions.show(rra, "1");
IntType f;
ImageJFunctions.show( Views.offsetInterval( rra, rra.getIntervalOfSizeOfStore() ), "1" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( -2, 0 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "2" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( dim[ 1 ], 1 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "3" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( M );
ra.setPosition( 32, 0 );
ra.setPosition( 17, 1 ); // 11 now, was 17 before
long[] pos = new long[ ra.numDimensions() ];
ra.localize( pos );
System.out.println( Arrays.toString( pos ) );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "4" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
// {
// RandomAccess<FloatType> accessToBeCollected = rra.randomAccess();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
// }
// System.gc();
// System.gc();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
}
示例8: chain
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void chain( final String[] args ) throws ImgIOException
{
final List< Shape > strel = StructuringElements.disk( 6, 2, 4 );
for ( final Shape shape : strel )
{
System.out.println( shape );
System.out.println( MorphologyUtils.printNeighborhood( shape, 2 ) );
}
ImageJ.main( args );
final String fn = "DrosophilaWing.tif";
final List< SCIFIOImgPlus< FloatType >> imgs = new
ImgOpener().openImgs( fn, new ArrayImgFactory< FloatType >(), new
FloatType() );
final Img< FloatType > img = imgs.get( 0 ).getImg();
// final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 800, 600 } );
// for ( final FloatType pixel : img )
// {
// pixel.set( 255f );
// }
// final ArrayRandomAccess< FloatType > ra = img.randomAccess();
// final Random ran = new Random( 1l );
// for ( int i = 0; i < 100; i++ )
// {
// final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
// final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
// ra.setPosition( new int[] { x, y } );
// ra.get().set( 0f );
// }
ImageJFunctions.show( img, "Source" );
final ExtendedRandomAccessibleInterval< FloatType, Img< FloatType >> extendZero = Views.extendZero( img );
// Open to provided target
final Interval interval2 = FinalInterval.createMinSize( new long[] { 280, 200, 185, 100 } );
final Img< FloatType > img2 = img.factory().create( interval2, new FloatType() );
final long[] translation = new long[ interval2.numDimensions() ];
interval2.min( translation );
final IntervalView< FloatType > translate = Views.translate( img2, translation );
Opening.open( extendZero, translate, strel, 1 );
ImageJFunctions.show( img2, "OpenedToTarget" );
// Open to new image
final Img< FloatType > img3 = Opening.open( img, strel, 1 );
ImageJFunctions.show( img3, "OpenedToNewImg" );
// Open in place
final Interval interval = FinalInterval.createMinSize( new long[] { 100, -10, 200, 200 } );
Opening.openInPlace( img, interval, strel, 1 );
ImageJFunctions.show( img, "OpenedInPlace" );
// BitType
final Img< BitType > bitImg = Thresholder.threshold( img, new FloatType( 200f ), true, 1 );
ImageJFunctions.show( bitImg, "BitSource" );
final ExtendedRandomAccessibleInterval< BitType, Img< BitType >> bitExtendZero = Views.extendZero( bitImg );
// Open to provided target
final Img< BitType > bitImg2 = bitImg.factory().create( interval2, new BitType() );
interval2.min( translation );
final IntervalView< BitType > bitTranslate = Views.translate( bitImg2, translation );
Opening.open( bitExtendZero, bitTranslate, strel, 1 );
ImageJFunctions.show( bitImg2, "BitOpenedToTarget" );
// Open to new image
final Img< BitType > bitImg3 = Opening.open( bitImg, strel, 1 );
ImageJFunctions.show( bitImg3, "bitOpenedToNewImg" );
// Open in place
Opening.openInPlace( bitImg, interval, strel, 1 );
ImageJFunctions.show( bitImg, "OpenedInPlace" );
}
示例9: show
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void show( final String[] args ) throws ImgIOException
{
ImageJ.main( args );
// final Shape strel = new DiamondShape( 3 );
final Shape strel = new HyperSphereShape( 6 );
final String fn = "DrosophilaWing.tif";
final List< SCIFIOImgPlus< FloatType >> imgs = new
ImgOpener().openImgs( fn, new ArrayImgFactory< FloatType >(), new
FloatType() );
final Img< FloatType > img = imgs.get( 0 ).getImg();
// final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 800, 600 } );
// for ( final FloatType pixel : img )
// {
// pixel.set( 255f );
// }
// final ArrayRandomAccess< FloatType > ra = img.randomAccess();
// final Random ran = new Random( 1l );
// for ( int i = 0; i < 100; i++ )
// {
// final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
// final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
// ra.setPosition( new int[] { x, y } );
// ra.get().set( 0f );
// }
ImageJFunctions.show( img, "Source" );
final ExtendedRandomAccessibleInterval< FloatType, Img< FloatType >> extendZero = Views.extendZero( img );
// Open to provided target
final Interval interval2 = FinalInterval.createMinSize( new long[] { 280, 200, 185, 100 } );
final Img< FloatType > img2 = img.factory().create( interval2, new FloatType() );
final long[] translation = new long[ interval2.numDimensions() ];
interval2.min( translation );
final IntervalView< FloatType > translate = Views.translate( img2, translation );
Opening.open( extendZero, translate, strel, 1 );
ImageJFunctions.show( img2, "OpenedToTarget" );
// Open to new image
final Img< FloatType > img3 = Opening.open( img, strel, 1 );
ImageJFunctions.show( img3, "OpenedToNewImg" );
// Open in place
final Interval interval = FinalInterval.createMinSize( new long[] { 100, -10, 200, 200 } );
Opening.openInPlace( img, interval, strel, 1 );
ImageJFunctions.show( img, "OpenedInPlace" );
// BitType
final Img< BitType > bitImg = Thresholder.threshold( img, new FloatType( 200f ), true, 1 );
ImageJFunctions.show( bitImg, "BitSource" );
final ExtendedRandomAccessibleInterval< BitType, Img< BitType >> bitExtendZero = Views.extendZero( bitImg );
// Open to provided target
final Img< BitType > bitImg2 = bitImg.factory().create( interval2, new BitType() );
interval2.min( translation );
final IntervalView< BitType > bitTranslate = Views.translate( bitImg2, translation );
Opening.open( bitExtendZero, bitTranslate, strel, 1 );
ImageJFunctions.show( bitImg2, "BitOpenedToTarget" );
// Open to new image
final Img< BitType > bitImg3 = Opening.open( bitImg, strel, 1 );
ImageJFunctions.show( bitImg3, "bitOpenedToNewImg" );
// Open in place
Opening.openInPlace( bitImg, interval, strel, 1 );
ImageJFunctions.show( bitImg, "OpenedInPlace" );
}
示例10: main
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void main( final String[] args ) throws ImgIOException
{
ImageJ.main( args );
final File file = new File( "DrosophilaWing.tif" );
final SCIFIOImgPlus img = new ImgOpener().openImgs( file.getAbsolutePath() ).get( 0 );
final Img< UnsignedByteType > imgInv = img.copy();
final Cursor< UnsignedByteType > cursor = img.cursor();
final Cursor< UnsignedByteType > cursor2 = imgInv.cursor();
while ( cursor.hasNext() )
{
cursor.fwd();
cursor2.fwd();
cursor2.get().set( 255 - cursor.get().get() );
}
final Shape strel = new HyperSphereShape( 5 );
/*
* To new Img
*/
ImageJFunctions.show( imgInv, "Source" );
final Img blackTopHat = BlackTopHat.blackTopHat( imgInv, strel, 1 );
ImageJFunctions.show( blackTopHat, "BlackTopHatToNewImg" );
/*
* In place
*/
final Interval interval = FinalInterval.createMinSize( new long[] { 7, 35, 88, 32 } );
final Img copy2 = imgInv.copy();
BlackTopHat.blackTopHatInPlace( copy2, interval, strel, 1 );
ImageJFunctions.show( copy2, "BlackTopHatInPlace" );
/*
* To target
*/
final Img img2 = img.factory().create( interval, new UnsignedByteType() );
final long[] translation = new long[ interval.numDimensions() ];
interval.min( translation );
final IntervalView translate = Views.translate( img2, translation );
BlackTopHat.blackTopHat( imgInv, translate, strel, 1 );
ImageJFunctions.show( img2, "BlackTopHatToTarget" );
}
示例11: chain
import net.imglib2.view.Views; //导入方法依赖的package包/类
private static void chain( final String[] args )
{
ImageJ.main( args );
final ArrayImg< UnsignedByteType, ByteArray > img = ArrayImgs.unsignedBytes( 50l, 50l );
for ( final UnsignedByteType pixel : img )
{
pixel.set( 255 );
}
final ArrayRandomAccess< UnsignedByteType > randomAccess = img.randomAccess();
randomAccess.setPosition( new int[] { 0, 25 } );
randomAccess.get().set( 0 );
randomAccess.setPosition( new int[] { 35, 25 } );
randomAccess.get().set( 0 );
final DiamondShape diamondShape = new DiamondShape( 8 );
ImageJFunctions.show( img, "Source" );
// New Source
ImageJFunctions.show( Erosion.erode( img, StructuringElements.diamond( 8, 2, true ), 1 ), "NewSourceDecomp" );
ImageJFunctions.show( Erosion.erode( img, StructuringElements.diamond( 8, 2, false ), 1 ), "NewSourceStraight" );
ImageJFunctions.show( Erosion.erode( img, diamondShape, 1 ), "NewSourceSingle" );
// Full
ImageJFunctions.show( Erosion.erodeFull( img, StructuringElements.diamond( 8, 2, true ), 1 ), "NewFullSourceDecomp" );
ImageJFunctions.show( Erosion.erodeFull( img, StructuringElements.diamond( 8, 2, false ), 1 ), "NewFullSourceStraight" );
ImageJFunctions.show( Erosion.erodeFull( img, diamondShape, 1 ), "NewFullSourceSingle" );
// To target
final Interval interval = FinalInterval.createMinSize( 10, 10, 20, 20 );
final long[] min = new long[ interval.numDimensions() ];
interval.min( min );
final Img< UnsignedByteType > result1 = img.factory().create( interval, img.firstElement().copy() );
final IntervalView< UnsignedByteType > target1 = Views.translate( result1, min );
Erosion.erode( img, target1, StructuringElements.diamond( 8, 2, true ), 1 );
ImageJFunctions.show( result1, "ToTargetDecomp" );
final Img< UnsignedByteType > result2 = img.factory().create( interval, img.firstElement().copy() );
final IntervalView< UnsignedByteType > target2 = Views.translate( result2, min );
Erosion.erode( img, target2, StructuringElements.diamond( 8, 2, false ), 1 );
ImageJFunctions.show( result2, "ToTargetStraight" );
final Img< UnsignedByteType > result3 = img.factory().create( interval, img.firstElement().copy() );
final IntervalView< UnsignedByteType > target3 = Views.translate( result3, min );
Erosion.erode( img, target3, diamondShape, 1 );
ImageJFunctions.show( result3, "ToTargetSingle" );
}
示例12: show
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void show( final String[] args ) throws ImgIOException
{
ImageJ.main( args );
final Shape strel = new DiamondShape( 3 );
final String fn = "DrosophilaWing.tif";
final List< SCIFIOImgPlus< FloatType >> imgs = new
ImgOpener().openImgs( fn, new ArrayImgFactory< FloatType >(), new
FloatType() );
final Img< FloatType > img = imgs.get( 0 ).getImg();
// final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 800, 600 } );
// final ArrayRandomAccess< FloatType > ra = img.randomAccess();
// final Random ran = new Random( 1l );
// for ( int i = 0; i < 100; i++ )
// {
// final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
// final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
// ra.setPosition( new int[] { x, y } );
// ra.get().set( 255f );
// }
ImageJFunctions.show( img, "Source" );
// Dilate to provided target
final Interval interval2 = FinalInterval.createMinSize( new long[] { 280, 200, 185, 100 } );
final Img< FloatType > img2 = img.factory().create( interval2, new FloatType() );
final long[] translation = new long[ interval2.numDimensions() ];
interval2.min( translation );
final IntervalView< FloatType > translate = Views.translate( img2, translation );
Dilation.dilate( img, translate, strel, 1 );
ImageJFunctions.show( img2, "DilatedToTarget" );
// Dilate to new image
final Img< FloatType > img3 = Dilation.dilate( img, strel, 1 );
ImageJFunctions.show( img3, "DilatedToNewImg" );
// Dilate to new image FULL version.
final Img< FloatType > img4 = Dilation.dilateFull( img, strel, 1 );
ImageJFunctions.show( img4, "DilatedToNewImgFULL" );
// Dilate in place
final Interval interval = FinalInterval.createMinSize( new long[] { 100, -10, 200, 200 } );
Dilation.dilateInPlace( img, interval, strel, 1 );
ImageJFunctions.show( img, "DilatedInPlace" );
/*
* Binary type
*/
final ArrayImg< BitType, LongArray > bitsImg = ArrayImgs.bits( new long[] { 800, 600 } );
final ArrayRandomAccess< BitType > raBits = bitsImg.randomAccess(); // LOL
final Random ran2 = new Random( 1l );
for ( int i = 0; i < 100; i++ )
{
final int x = ran2.nextInt( ( int ) bitsImg.dimension( 0 ) );
final int y = ran2.nextInt( ( int ) bitsImg.dimension( 1 ) );
raBits.setPosition( new int[] { x, y } );
raBits.get().set( true );
}
ImageJFunctions.show( bitsImg, "BitsSource" );
// Dilate to new image
final Img< BitType > imgBits3 = Dilation.dilate( bitsImg, strel, 1 );
ImageJFunctions.show( imgBits3, "BitsDilatedToNewImg" );
}
示例13: chain
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void chain( final String[] args ) throws ImgIOException
{
final List< Shape > strel = StructuringElements.disk( 6, 2, 4 );
for ( final Shape shape : strel )
{
System.out.println( shape );
System.out.println( MorphologyUtils.printNeighborhood( shape, 2 ) );
}
ImageJ.main( args );
final String fn = "DrosophilaWing.tif";
final List< SCIFIOImgPlus< UnsignedByteType >> imgs = new
ImgOpener().openImgs( fn, new ArrayImgFactory< UnsignedByteType >(), new
UnsignedByteType() );
final Img< UnsignedByteType > img = imgs.get( 0 ).getImg();
// final ArrayImg< UnsignedByteType, FloatArray > img = ArrayImgs.floats( new long[] { 800, 600 } );
// for ( final UnsignedByteType pixel : img )
// {
// pixel.set( 255f );
// }
// final ArrayRandomAccess< UnsignedByteType > ra = img.randomAccess();
// final Random ran = new Random( 1l );
// for ( int i = 0; i < 100; i++ )
// {
// final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
// final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
// ra.setPosition( new int[] { x, y } );
// ra.get().set( 0f );
// }
ImageJFunctions.show( img, "Source" );
final ExtendedRandomAccessibleInterval< UnsignedByteType, Img< UnsignedByteType >> extendZero = Views.extendZero( img );
// Close to provided target
final Interval interval2 = FinalInterval.createMinSize( new long[] { 280, 200, 185, 100 } );
final Img< UnsignedByteType > img2 = img.factory().create( interval2, new UnsignedByteType() );
final long[] translation = new long[ interval2.numDimensions() ];
interval2.min( translation );
final IntervalView< UnsignedByteType > translate = Views.translate( img2, translation );
Closing.close( extendZero, translate, strel, 1 );
ImageJFunctions.show( img2, "ClosedToTarget" );
// Close to new image
final Img< UnsignedByteType > img3 = Closing.close( img, strel, 1 );
ImageJFunctions.show( img3, "ClosedToNewImg" );
// Close in place
final Interval interval = FinalInterval.createMinSize( new long[] { 100, -10, 200, 200 } );
Closing.closeInPlace( img, interval, strel, 1 );
ImageJFunctions.show( img, "ClosedInPlace" );
// BitType
final Img< BitType > bitImg = Thresholder.threshold( img, new UnsignedByteType( 100 ), true, 1 );
ImageJFunctions.show( bitImg, "BitSource" );
final ExtendedRandomAccessibleInterval< BitType, Img< BitType >> bitExtendZero = Views.extendZero( bitImg );
// Close to provided target
final Img< BitType > bitImg2 = bitImg.factory().create( interval2, new BitType() );
interval2.min( translation );
final IntervalView< BitType > bitTranslate = Views.translate( bitImg2, translation );
Closing.close( bitExtendZero, bitTranslate, strel, 1 );
ImageJFunctions.show( bitImg2, "BitClosedToTarget" );
// Close to new image
final Img< BitType > bitImg3 = Closing.close( bitImg, strel, 1 );
ImageJFunctions.show( bitImg3, "bitClosedToNewImg" );
// Close in place
Closing.closeInPlace( bitImg, interval, strel, 1 );
ImageJFunctions.show( bitImg, "ClosedInPlace" );
}
示例14: show
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static void show( final String[] args ) throws ImgIOException
{
ImageJ.main( args );
final Shape strel = new DiamondShape( 3 );
// final Shape strel = new HyperSphereShape( 6 );
final String fn = "DrosophilaWing.tif";
final List< SCIFIOImgPlus< UnsignedByteType >> imgs = new
ImgOpener().openImgs( fn, new ArrayImgFactory< UnsignedByteType >(), new
UnsignedByteType() );
final Img< UnsignedByteType > img = imgs.get( 0 ).getImg();
// final ArrayImg< UnsignedByteType, FloatArray > img = ArrayImgs.floats( new long[] { 800, 600 } );
// for ( final UnsignedByteType pixel : img )
// {
// pixel.set( 255f );
// }
// final ArrayRandomAccess< UnsignedByteType > ra = img.randomAccess();
// final Random ran = new Random( 1l );
// for ( int i = 0; i < 100; i++ )
// {
// final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
// final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
// ra.setPosition( new int[] { x, y } );
// ra.get().set( 0f );
// }
ImageJFunctions.show( img, "Source" );
final ExtendedRandomAccessibleInterval< UnsignedByteType, Img< UnsignedByteType >> extendZero = Views.extendZero( img );
// Close to provided target
final Interval interval2 = FinalInterval.createMinSize( new long[] { 280, 200, 185, 100 } );
final Img< UnsignedByteType > img2 = img.factory().create( interval2, new UnsignedByteType() );
final long[] translation = new long[ interval2.numDimensions() ];
interval2.min( translation );
final IntervalView< UnsignedByteType > translate = Views.translate( img2, translation );
Closing.close( extendZero, translate, strel, 1 );
ImageJFunctions.show( img2, "ClosedToTarget" );
// Close to new image
final Img< UnsignedByteType > img3 = Closing.close( img, strel, 1 );
ImageJFunctions.show( img3, "ClosedToNewImg" );
// Close in place
final Interval interval = FinalInterval.createMinSize( new long[] { 100, -10, 200, 200 } );
Closing.closeInPlace( img, interval, strel, 1 );
ImageJFunctions.show( img, "ClosedInPlace" );
// BitType
final Img< BitType > bitImg = Thresholder.threshold( img, new UnsignedByteType( 100 ), true, 1 );
ImageJFunctions.show( bitImg, "BitSource" );
final ExtendedRandomAccessibleInterval< BitType, Img< BitType >> bitExtendZero = Views.extendZero( bitImg );
// Close to provided target
final Img< BitType > bitImg2 = bitImg.factory().create( interval2, new BitType() );
interval2.min( translation );
final IntervalView< BitType > bitTranslate = Views.translate( bitImg2, translation );
Closing.close( bitExtendZero, bitTranslate, strel, 1 );
ImageJFunctions.show( bitImg2, "BitClosedToTarget" );
// Close to new image
final Img< BitType > bitImg3 = Closing.close( bitImg, strel, 1 );
ImageJFunctions.show( bitImg3, "bitClosedToNewImg" );
// Close in place
Closing.closeInPlace( bitImg, interval, strel, 1 );
ImageJFunctions.show( bitImg, "ClosedInPlace" );
}
示例15: calculate
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public IntervalView<T> calculate(final RandomAccessibleInterval<T> input) {
return Views.translate(input, translation);
}