本文整理汇总了Java中net.imglib2.img.array.ArrayImgs.floats方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayImgs.floats方法的具体用法?Java ArrayImgs.floats怎么用?Java ArrayImgs.floats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.array.ArrayImgs
的用法示例。
在下文中一共展示了ArrayImgs.floats方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFloatImage
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval< FloatType > getFloatImage(
int timepointId, boolean normalize, ImgLoaderHint... hints )
{
final Random rnd = new Random( setupId );
final Img< FloatType > img = ArrayImgs.floats( 512, 512, 86 );
final float scale;
if ( normalize )
scale = 1;
else
scale = 20000;
for ( final FloatType t : img )
t.set( rnd.nextFloat() * scale);
return img;
}
示例2: copyChannel
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static Img< FloatType > copyChannel( final ImagePlus imp, final int channel )
{
final int w, h, d;
Img< FloatType > img = ArrayImgs.floats( w = imp.getWidth(), h = imp.getHeight(), d = imp.getNSlices() );
final Cursor< FloatType > 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;
}
示例3: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main( String[] args )
{
new ImageJ();
Img< FloatType > img = ArrayImgs.floats( 500, 500 );
BlendingRealRandomAccess blend = new BlendingRealRandomAccess(
img,
new float[]{ 100, 0 },
new float[]{ 12, 150 } );
Cursor< FloatType > c = img.localizingCursor();
while ( c.hasNext() )
{
c.fwd();
blend.setPosition( c );
c.get().setReal( blend.get().getRealFloat() );
}
ImageJFunctions.show( img );
}
示例4: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
final static public void main( final String[] args )
{
new ImageJ();
final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
imp.show();
final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );
final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
for ( int i = 0; i < lut.length; ++i )
lut[ i ] = i + Math.pow( i, 1.5 );
final SingleDimensionLUTRealTransform transform = new SingleDimensionLUTRealTransform( lut, 2, 2, 1 );
final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );
// RealViews.transformReal(source, transform);
ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
}
示例5: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main( final String[] args ) throws ImgIOException
{
final String fn = "/home/tobias/workspace/data/DrosophilaWing.tif";
final Img< FloatType > img = new ImgOpener().openImg( fn, new ArrayImgFactory< FloatType >(), new FloatType() );
final long[] dims = new long[ img.numDimensions() ];
img.dimensions( dims );
final Img< FloatType > convolved = ArrayImgs.floats( dims );
try
{
Gauss3.gauss( 3, Views.extendMirrorSingle( img ), convolved );
// Gauss3.gauss( 5, img, Views.interval( convolved, Intervals.createMinSize( 200, 100, 200, 150 ) ) );
}
catch ( final IncompatibleTypeException e )
{
e.printStackTrace();
}
ImageJFunctions.show( convolved );
}
示例6: createFloatArray
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
private static float[] createFloatArray(
final RandomAccessibleInterval<FloatType> image)
{
final long[] dims = Intervals.dimensionsAsLongArray(image);
final ArrayImg<FloatType, FloatArray> dest = ArrayImgs.floats(dims);
copy(image, dest);
return dest.update(null).getCurrentStorageArray();
}
示例7: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main(String... args) {
// SETUP
final ImageJ imageJ = new ImageJ();
final Random random = new Random();
final int width = 100;
final int height = 100;
final int depth = 100;
final int rotations = 100;
final int bins = 100;
final Img<FloatType> img = ArrayImgs.floats(width, height, depth);
@SuppressWarnings("unchecked")
final BinaryFunctionOp<ValuePair<Point3d, Vector3d>, Interval, Optional<ValuePair<DoubleType, DoubleType>>> intersectOp =
(BinaryFunctionOp) Functions.binary(imageJ.op(), BoxIntersect.class,
Optional.class, ValuePair.class, img);
final BinaryHybridCFI1<Tuple3d, AxisAngle4d, Tuple3d> rotateOp = Hybrids
.binaryCFI1(imageJ.op(), RotateAboutAxis.class, Tuple3d.class,
new Vector3d(), new AxisAngle4d());
// EXECUTE
for (int i = 0; i < rotations; i++) {
final AxisAngle4d rotation = RotateAboutAxis.randomAxisAngle();
final LineGrid grid = createGrid(img, rotateOp, rotation, random);
final Stream<Section> sections = createSections(img, grid, bins,
intersectOp);
sections.forEach(s -> sample(img, s, 1.0, random));
}
// DISPLAY RESULT
final ImgPlus<FloatType> image = new ImgPlus<>(img, "Sampling count",
new DefaultLinearAxis(Axes.X), new DefaultLinearAxis(Axes.Y),
new DefaultLinearAxis(Axes.Z));
imageJ.launch(args);
imageJ.ui().show(image);
}
示例8: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main(final String... args) {
// SETUP
final ImageJ imageJ = new ImageJ();
final Random random = new Random();
final int width = 100;
final int height = 100;
final int depth = 100;
final int rotations = 100;
final int bins = 100;
final Img<FloatType> img = ArrayImgs.floats(width, height, depth, 3);
@SuppressWarnings("unchecked")
final BinaryFunctionOp<ValuePair<Point3d, Vector3d>, Interval, Optional<ValuePair<DoubleType, DoubleType>>> intersectOp =
(BinaryFunctionOp) Functions.binary(imageJ.op(), BoxIntersect.class,
Optional.class, ValuePair.class, img);
final BinaryHybridCFI1<Tuple3d, AxisAngle4d, Tuple3d> rotateOp = Hybrids
.binaryCFI1(imageJ.op(), RotateAboutAxis.class, Tuple3d.class,
new Vector3d(), new AxisAngle4d());
// EXECUTE
for (int i = 0; i < rotations; i++) {
final AxisAngle4d rotation = RotateAboutAxis.randomAxisAngle();
final LineGrid grid = createGrid(img, rotateOp, rotation, random);
final Stream<Section> sections = createSections(img, grid, bins,
intersectOp);
sections.forEach(s -> sample(img, s, 1.0, random));
}
// DISPLAY RESULTS
// Swap channel- and z-axes swapped so that image displays OK.
final IntervalView<FloatType> displayView = Views.permute(img, 3, 2);
final Img<FloatType> displayImg = ImgView.wrap(displayView, img.factory());
final ImgPlus<FloatType> image = new ImgPlus<>(displayImg,
"Sampling directions", new DefaultLinearAxis(Axes.X),
new DefaultLinearAxis(Axes.Y), new DefaultLinearAxis(Axes.CHANNEL),
new DefaultLinearAxis(Axes.Z));
imageJ.launch(args);
imageJ.ui().show(image);
}
示例9: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
final static public void main( final String[] args )
{
new ImageJ();
final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
imp.show();
final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );
final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
for ( int i = 0; i < lut.length; ++i )
lut[ i ] = i + Math.pow( i, 1.5 );
final LUTRealTransform transform = new LUTRealTransform( lut, 2, 2 );
final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );
// RealViews.transformReal(source, transform);
final ArrayImg< FloatType, FloatArray > targetImg = ArrayImgs.floats( imp.getWidth(), imp.getHeight() );
render( source, targetImg, transform, 0.05 );
ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
ImageJFunctions.show( targetImg );
}
示例10: generateFloatImg
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
private static Img<FloatType> generateFloatImg(final float[] values) {
final float[] array =
new float[(int) Intervals.numElements(new FinalInterval(dims))];
if (array.length != values.length) {
throw new RuntimeException("Number of values doesn't match dimmensions");
}
for (int i = 0; i < array.length; i++) {
array[i] = values[i];
}
return ArrayImgs.floats(array, dims);
}
示例11: generateFloatArrayTestImg
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public ArrayImg<FloatType, FloatArray> generateFloatArrayTestImg(
final boolean fill, final long... dims)
{
final float[] array = new float[(int) Intervals.numElements(
new FinalInterval(dims))];
if (fill) {
seed = 17;
for (int i = 0; i < array.length; i++) {
array[i] = (float) pseudoRandom() / (float) Integer.MAX_VALUE;
}
}
return ArrayImgs.floats(array, dims);
}
示例12: regressionTest
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Test
public void regressionTest() throws Exception {
// load in input image and expected output image.
Img<FloatType> inputImg = (Img<FloatType>) ops.run(
net.imagej.ops.image.equation.DefaultEquation.class,
"Math.tan(0.3*p[0]) + Math.tan(0.1*p[1])");
Img<FloatType> expectedOutput = ((Img<FloatType>) openFloatImg(
"Result.tif"));
// create ouput image
long[] dims = new long[inputImg.numDimensions()];
inputImg.dimensions(dims);
Img<FloatType> actualOutput = ArrayImgs.floats(dims);
// scale over which the filter operates (sensitivity)
int scale = 1;
// physical spacing between data points (1,1 since I got it from the
// computer)
double[] spacing = { 1, 1 };
// run the op
ops.run(net.imagej.ops.filter.vesselness.DefaultFrangi.class, actualOutput,
inputImg, spacing, scale);
// compare the output image data to that stored in the file.
Cursor<FloatType> cursor = Views.iterable(actualOutput).localizingCursor();
RandomAccess<FloatType> actualRA = actualOutput.randomAccess();
RandomAccess<FloatType> expectedRA = expectedOutput.randomAccess();
while (cursor.hasNext()) {
cursor.fwd();
actualRA.setPosition(cursor);
expectedRA.setPosition(cursor);
assertEquals(expectedRA.get().get(), actualRA.get().get(), 0);
}
}
示例13: getFloatImage
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize )
{
try
{
final MultipageTiffReader r = new MultipageTiffReader( mmFile );
final ArrayImg< FloatType, ? > img = ArrayImgs.floats( r.width(), r.height(), r.depth() );
final BasicViewDescription< ? > vd = sequenceDescription.getViewDescriptions().get( view );
populateImage( img, vd, r );
if ( normalize )
normalize( img );
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;
}
}
示例14: getFloatImage
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize )
{
final BasicViewDescription< ? > vd = sd.getViewDescriptions().get( view );
final Dimensions d = vd.getViewSetup().getSize();
final VoxelDimensions dv = vd.getViewSetup().getVoxelSize();
final ArrayImg< FloatType, ? > img = ArrayImgs.floats( 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 );
if ( normalize )
normalize( img );
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;
}
示例15: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main( String[] args )
{
// define the blocksize so that it is one single block
final RandomAccessibleInterval< FloatType > block = ArrayImgs.floats( 384, 384 );
final long[] blockSize = new long[ block.numDimensions() ];
block.dimensions( blockSize );
final RandomAccessibleInterval< FloatType > image = ArrayImgs.floats( 1024, 1024 );
final long[] imgSize = new long[ image.numDimensions() ];
image.dimensions( imgSize );
// whatever the kernel size is (extra size/2 in general)
final long[] kernelSize = new long[]{ 16, 32 };
final BlockGeneratorFixedSizePrecise blockGenerator = new BlockGeneratorFixedSizePrecise( blockSize );
final Block[] blocks = blockGenerator.divideIntoBlocks( imgSize, kernelSize );
int i = 0;
for ( final Block b : blocks )
{
// copy data from the image to the block (including extra space for outofbounds/real image data depending on kernel size)
b.copyBlock( Views.extendMirrorDouble( image ), block );
// do something with the block (e.g. also multithreaded, cluster, ...)
for ( final FloatType f : Views.iterable( block ) )
f.set( i );
++i;
// write the block back (use a temporary image if multithreaded or in general not all are copied first)
b.pasteBlock( image, block );
}
ImageJFunctions.show( image );
}