本文整理汇总了Java中net.imglib2.img.imageplus.ImagePlusImgFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java ImagePlusImgFactory.create方法的具体用法?Java ImagePlusImgFactory.create怎么用?Java ImagePlusImgFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.imageplus.ImagePlusImgFactory
的用法示例。
在下文中一共展示了ImagePlusImgFactory.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyToFloatImagePlus
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的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;
}
}
示例2: copyToImagePlus
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的package包/类
public static < T extends NativeType< T >> ImagePlusImg<T, ?> copyToImagePlus(
RandomAccessible<T> img,
IterableInterval<?> interval
) throws Exception {
ImagePlusImgFactory<T> factory = new ImagePlusImgFactory<T>();
T t = img.randomAccess().get();
ImagePlusImg<T, ?> ipImg = factory.create(interval,t);
logger.debug("create image plus of type: " + t.getClass());
logger.debug("result is of type: " + ipImg.firstElement().getClass());
Cursor<T> c_in = ipImg.cursor();
RandomAccess<T> ra = img.randomAccess();
while(c_in.hasNext()){
c_in.fwd();
ra.setPosition(c_in);
ra.get().set(c_in.get());
}
return ipImg;
}
示例3: copyToImageStack
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的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;
}
示例4: debugVisEdgelView
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的package包/类
public void debugVisEdgelView(int i, Edgel e, Edgel f){
RandomAccessible<T> ev =
EdgelTools.edgelToView(e, img, patchSize);
RandomAccessible<T> fv =
EdgelTools.edgelToView(f, img, patchSize);
// ArrayImgFactory<T> ubfactory = new ArrayImgFactory<T>();
ImagePlusImgFactory<T> ipfactory = new ImagePlusImgFactory<T>();
Img<T> ePatchImg = ipfactory.create(patchSize, mask.firstElement());
Img<T> fPatchImg = ipfactory.create(patchSize, mask.firstElement());
logger.debug( " copying " );
ImgOps.copyInto(ev, ePatchImg);
ImgOps.copyInto(fv, fPatchImg);
logger.debug( " done copying " );
logger.debug( " writing patches " );
ImgOps.writeFloat( ePatchImg,
String.format("%s/patch_%03d_%s_.tif", debugDir, debugSuffix, i));
ImgOps.writeFloat( fPatchImg,
String.format("%s/patch_%03d_match_%s_.tif",debugDir, debugSuffix, i));
logger.debug( " done writing patches " );
}
示例5: testPca
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的package包/类
@Test
public void testPca(){
System.out.println("testPcaReg");
int[] sz = new int[]{ 27,27,27 };
double[] ctr = ArrayUtil.toDouble( PatchTools.patchSizeToMidpt( sz ));
double[] sigs = new double[]{1, 10, 0.1};
// double mint = -1;
// double maxt = 1.5;
double mint = -1;
double maxt = 9e20;
ImagePlusImgFactory<FloatType> factory = new ImagePlusImgFactory<FloatType>();
Img<FloatType> img = ImgOps.createGaussianEllipseImg(factory, sz, ctr, sigs, mint, maxt, new FloatType());
ImgOps.writeFloat(img, "/groups/jain/home/bogovicj/projects/crackPatching/toyData/ellipseImg.tif");
AffineTransform3D xfm = TransformTools.rotationCentered(2, Math.PI/8, ctr);
RealTransformRandomAccessible<FloatType, InverseRealTransform> imgXfm =
TransformTools.xfmToView(xfm,
Views.extendZero(img), new NLinearInterpolatorFactory<FloatType>());
ImagePlusImg<FloatType, ?> imgXfmOut = factory.create(img, img.firstElement());
ImgOps.copyInto( imgXfm, imgXfmOut);
ImgMoment tgtMom = new ImgMoment();
double[] tgtOr = tgtMom.orientation(imgXfmOut);
tgtMom.orientationEvalsEvecs(tgtOr);
System.out.println("tgt or: " + ArrayUtil.printArray(tgtOr));
System.out.println("tgt cent: " + ArrayUtil.printArray(tgtMom.centroid()));
DenseMatrix64F srcR = new DenseMatrix64F( 3, 3 );
srcR.setData( tgtMom.getEvecs() );
DenseMatrix64F srcMtx = TransformTools.rotationCenteredMtx(srcR, tgtMom.centroid());
}
示例6: main
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的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();
}
}
示例7: testPcaReg
import net.imglib2.img.imageplus.ImagePlusImgFactory; //导入方法依赖的package包/类
@Test
public void testPcaReg(){
System.out.println("testPcaReg");
int[] sz = new int[]{ 27,27,27 };
double[] ctr = ArrayUtil.toDouble( PatchTools.patchSizeToMidpt( sz ));
double[] sigs = new double[]{1, 10, 0.1};
// double mint = -1;
// double maxt = 1.5;
double mint = -1;
double maxt = 9e20;
ImagePlusImgFactory<FloatType> factory = new ImagePlusImgFactory<FloatType>();
Img<FloatType> img = ImgOps.createGaussianEllipseImg(factory, sz, ctr, sigs, mint, maxt, new FloatType());
ImgOps.writeFloat(img, "/groups/jain/home/bogovicj/projects/crackPatching/toyData/ellipseImg.tif");
AffineTransform3D xfm = TransformTools.rotationCentered(2, Math.PI/8, ctr);
RealTransformRandomAccessible<FloatType, InverseRealTransform> imgXfm =
TransformTools.xfmToView(xfm,
Views.extendZero(img), new NLinearInterpolatorFactory<FloatType>());
ImagePlusImg<FloatType, ?> imgXfmOut = factory.create(img, img.firstElement());
ImgOps.copyInto( imgXfm, imgXfmOut);
ImgOps.writeFloat(imgXfmOut, "/groups/jain/home/bogovicj/projects/crackPatching/toyData/ellipseImgXfm.tif");
AffineTransform xfmEst = TransformTools.rotationPca( imgXfmOut, img);
System.out.println("xfmEst:\n" + TransformTools.printAffineTransform(xfmEst));
// AffineTransform xfmCat = xfmEst.preConcatenate(xfm);
// System.out.println("xfmCat:\n" + TransformTools.printAffineTransform(xfmCat));
RealTransformRandomAccessible<FloatType, InverseRealTransform> img2XfmXfm =
TransformTools.xfmToView( xfmEst,
Views.extendZero(imgXfmOut), new NLinearInterpolatorFactory<FloatType>());
ImagePlusImg<FloatType, ?> img2xfmxfmout = factory.create(img, img.firstElement());
ImgOps.copyInto( img2XfmXfm, img2xfmxfmout);
ImgOps.writeFloat(img2xfmxfmout, "/groups/jain/home/bogovicj/projects/crackPatching/toyData/ellipseImg2XfmInv.tif");
System.out.println("done");
assertTrue(true);
}