本文整理汇总了Java中io.scif.img.SCIFIOImgPlus类的典型用法代码示例。如果您正苦于以下问题:Java SCIFIOImgPlus类的具体用法?Java SCIFIOImgPlus怎么用?Java SCIFIOImgPlus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SCIFIOImgPlus类属于io.scif.img包,在下文中一共展示了SCIFIOImgPlus类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import io.scif.img.SCIFIOImgPlus; //导入依赖的package包/类
@Override
public Dataset open(final String source, final SCIFIOConfig config)
throws IOException
{
final ImgOpener imageOpener = new ImgOpener(getContext());
try {
// TODO openImgs we are only using the first image index in the
// SCIFIOConfig.imgOpenerGetRange - so this image index corresponds to the
// first ImgPlus in the list returned by the ImgOpener. See
// https://github.com/scifio/scifio/issues/259
final SCIFIOImgPlus<?> imgPlus =
imageOpener.openImgs(source, config).get(0);
@SuppressWarnings({ "rawtypes", "unchecked" })
final Dataset dataset = datasetService.create((ImgPlus) imgPlus);
final ImageMetadata imageMeta = imgPlus.getImageMetadata();
updateDataset(dataset, imageMeta);
return dataset;
}
catch (final ImgIOException exc) {
throw new IOException(exc);
}
}
示例2: openAll
import io.scif.img.SCIFIOImgPlus; //导入依赖的package包/类
@Override
public List<net.imagej.Dataset> openAll(String source, SCIFIOConfig config)
throws IOException
{
final ArrayList<Dataset> datasetList = new ArrayList<>();
final ImgOpener imageOpener = new ImgOpener(getContext());
try {
final List<SCIFIOImgPlus<?>> openImgs = imageOpener.openImgs(source, config);
for (int imgId = 0; imgId != openImgs.size(); imgId++) {
final SCIFIOImgPlus<?> imgPlus = openImgs.get(imgId);
@SuppressWarnings({"rawtypes", "unchecked"})
final Dataset dataset = datasetService.create((ImgPlus) imgPlus);
final ImageMetadata imageMeta = imgPlus.getImageMetadata();
updateDataset(dataset, imageMeta);
datasetList.add(dataset);
}
} catch (final ImgIOException exc) {
throw new IOException(exc);
}
return datasetList;
}
示例3: show
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}
示例4: main
import io.scif.img.SCIFIOImgPlus; //导入依赖的package包/类
public static void main(final String... args) throws ImgIOException {
final JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) return;
final File file = fileChooser.getSelectedFile();
final SCIFIO scifio = new SCIFIO();
final List<SCIFIOImgPlus<?>> imgs = //
new ImgOpener(scifio.context()).openImgs(file.getAbsolutePath());
System.out.println("Found " + imgs.size() + " images");
for (final SCIFIOImgPlus<?> img : imgs) {
System.out.println("\t" + img);
}
scifio.context().dispose();
}
示例5: testReaderCleanup
import io.scif.img.SCIFIOImgPlus; //导入依赖的package包/类
/**
* Test that when a {@link SCIFIOCellImg} is opened and disposed, the
* associated reader is closed.
*/
@Test
public void testReaderCleanup() {
// Make an id that will trigger cell creation
final String id = "lotsofplanes&axes=X,Y,Z&lengths=256,256,100000.fake";
final SCIFIOImgPlus<?> img = IO.open(id);
assertNotNull(((SCIFIOCellImg) img.getImg()).reader().getMetadata());
img.dispose();
assertNull(((SCIFIOCellImg) img.getImg()).reader().getMetadata());
}
示例6: chain
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}
示例7: show
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}
示例8: main
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}
示例9: show
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}
示例10: chain
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}
示例11: show
import io.scif.img.SCIFIOImgPlus; //导入依赖的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" );
}