本文整理汇总了Java中net.imglib2.img.array.ArrayImgs.unsignedShorts方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayImgs.unsignedShorts方法的具体用法?Java ArrayImgs.unsignedShorts怎么用?Java ArrayImgs.unsignedShorts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.array.ArrayImgs
的用法示例。
在下文中一共展示了ArrayImgs.unsignedShorts方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyChannelUSST
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static Img< UnsignedShortType > copyChannelUSST( final ImagePlus imp, final int channel )
{
final int w, h, d;
Img< UnsignedShortType > img = ArrayImgs.unsignedShorts( w = imp.getWidth(), h = imp.getHeight(), d = imp.getNSlices() );
final Cursor< UnsignedShortType > c = img.cursor();
for ( int z = 0; z < d; ++z )
{
final int[] pixels = (int[])imp.getStack().getProcessor( z + 1 ).getPixels();
for ( int i = 0; i < w*h; ++i )
{
if ( channel == 0 )
c.next().set( ( pixels[ i ] & 0xff0000) >> 16 );
else if ( channel == 1 )
c.next().set( ( pixels[ i ] & 0xff00 ) >> 8 );
else
c.next().set( pixels[ i ] & 0xff );
}
}
return img;
}
示例2: initialize
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Before
public void initialize() {
final long[] dimensions = new long[] { xSize, ySize };
final Random r = new Random(0xdeadbeef);
// create image and output
in = ArrayImgs.unsignedShorts(dimensions);
final RandomAccess<UnsignedShortType> ra = in.randomAccess();
// populate pixel values with a ramp function + a constant
for (int x = 0; x < xSize; x++) {
for (int y = 0; y < ySize; y++) {
ra.setPosition(new int[] { x, y });
ra.get().setReal(r.nextInt(65535));
}
}
}
示例3: getImage
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval< UnsignedShortType > getImage( final ViewId view )
{
try
{
final MultipageTiffReader r = new MultipageTiffReader( mmFile );
final ArrayImg< UnsignedShortType, ? > img = ArrayImgs.unsignedShorts( r.width(), r.height(), r.depth() );
final BasicViewDescription< ? > vd = sequenceDescription.getViewDescriptions().get( view );
populateImage( img, vd, r );
updateMetaDataCache( view, r.width(), r.height(), r.depth(), r.calX(), r.calY(), r.calZ() );
r.close();
return img;
}
catch ( Exception e )
{
IOFunctions.printlnSafe( "Failed to load viewsetup=" + view.getViewSetupId() + " timepoint=" + view.getTimePointId() + ": " + e );
e.printStackTrace();
return null;
}
}
示例4: getImage
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval< UnsignedShortType > getImage( final ViewId view )
{
final BasicViewDescription< ? > vd = sd.getViewDescriptions().get( view );
final Dimensions d = vd.getViewSetup().getSize();
final VoxelDimensions dv = vd.getViewSetup().getVoxelSize();
final ArrayImg< UnsignedShortType, ? > img = ArrayImgs.unsignedShorts( d.dimension( 0 ), d.dimension( 1 ), d.dimension( 2 ) );
final String ampOrPhaseDir;
if ( vd.getViewSetup().getAttribute( Channel.class ).getId() == ampChannelId )
ampOrPhaseDir = amplitudeDir;
else if ( vd.getViewSetup().getAttribute( Channel.class ).getId() == phaseChannelId )
ampOrPhaseDir = phaseDir;
else
throw new RuntimeException( "viewSetupId=" + view.getViewSetupId() + " is not Amplitude nor phase." );
populateImage( img, directory, stackDir, ampOrPhaseDir, zPlanes, timepoints.get( view.getTimePointId() ), extension );
updateMetaDataCache( view, (int)d.dimension( 0 ), (int)d.dimension( 1 ), (int)d.dimension( 2 ), dv.dimension( 0 ), dv.dimension( 1 ), dv.dimension( 2 ) );
return img;
}
示例5: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main( final String[] args )
{
ImageJ.main( args );
final String fn = "/Users/pietzsch/Desktop/data/cca2.tif";
final RandomAccessibleInterval< UnsignedByteType > img = IO.openImgs( fn, new ArrayImgFactory< UnsignedByteType >(), new UnsignedByteType() ).get( 0 ).getImg();
final long[] dims = new long[ img.numDimensions() ];
img.dimensions( dims );
final RandomAccessibleInterval< UnsignedShortType > indexImg = ArrayImgs.unsignedShorts( dims );
final ImgLabeling< Integer, UnsignedShortType > labeling = new ImgLabeling< Integer, UnsignedShortType >( indexImg );
final Iterator< Integer > labels = new Iterator< Integer >()
{
private int i = 1;
@Override
public boolean hasNext()
{
return true;
}
@Override
public Integer next()
{
return i++;
}
@Override
public void remove()
{}
};
ConnectedComponents.labelAllConnectedComponents( img, labeling, labels, FOUR_CONNECTED );
final Img< ARGBType > argb = ArrayImgs.argbs( dims );
colorLabels( labeling, new ColorStream().iterator(), argb );
ImageJFunctions.show( argb );
}
示例6: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
static public final void main(String[] arg) {
final String src = "/home/albert/lab/TEM/abd/microvolumes/Seg/180-220-int/180-220-int-00.tif";
try {
final Img<UnsignedByteType> img = new ImgOpener().openImg(src, new ArrayImgFactory<UnsignedByteType>(), new UnsignedByteType());
// copy as short
Img<UnsignedShortType> copyShort = ArrayImgs.unsignedShorts(Intervals.dimensionsAsLongArray(img));
Cursor<UnsignedByteType> c1 = img.cursor();
Cursor<UnsignedShortType> c2 = copyShort.cursor();
while (c1.hasNext()) {
c2.next().setInteger(c1.next().get());
}
// copy as float
Img<FloatType> copyFloat = ArrayImgs.floats(Intervals.dimensionsAsLongArray(img));
c1.reset();
Cursor<FloatType> c3 = copyFloat.cursor();
while (c1.hasNext()) {
c3.next().setReal(c1.next().get());
}
final int nIterations = 5;
// Test as byte
System.out.println("As byte/long: ");
for (int i=0; i < nIterations; ++i) {
test(img, new LongType());
}
System.out.println("As byte/int: ");
for (int i=0; i < nIterations; ++i) {
test(img, new IntType());
}
// Test as short
System.out.println("As short/long: ");
for (int i=0; i < nIterations; ++i) {
test(copyShort, new LongType());
}
System.out.println("As short/int: ");
for (int i=0; i < nIterations; ++i) {
test(copyShort, new LongType());
}
// Test as float
System.out.println("As float/double: ");
for (int i=0; i < nIterations; ++i) {
test(copyFloat, new DoubleType());
}
} catch (Exception e) {
e.printStackTrace();
}
}