本文整理汇总了Java中net.imglib2.realtransform.RealViews.transform方法的典型用法代码示例。如果您正苦于以下问题:Java RealViews.transform方法的具体用法?Java RealViews.transform怎么用?Java RealViews.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.realtransform.RealViews
的用法示例。
在下文中一共展示了RealViews.transform方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.imglib2.realtransform.RealViews; //导入方法依赖的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() ) ) );
}
示例2: getAccessor
import net.imglib2.realtransform.RealViews; //导入方法依赖的package包/类
/**
* Logic stolen from
* <a href='https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/org/janelia/intensity/LinearIntensityMap.java'>
* TrakEM2 LinearIntensityMap
* </a>.
*
* @return an accessor for deriving warped pixel intensities.
*/
public RealRandomAccess<RealComposite<DoubleType>> getAccessor() {
final ArrayImg<DoubleType, DoubleArray> warpField =
ArrayImgs.doubles(values, columnCount, rowCount, VALUES_PER_AFFINE);
final CompositeIntervalView<DoubleType, RealComposite<DoubleType>>
collapsedSource = Views.collapseReal(warpField);
final RandomAccessible<RealComposite<DoubleType>> extendedCollapsedSource = Views.extendBorder(collapsedSource);
final RealRandomAccessible<RealComposite<DoubleType>> coefficients =
Views.interpolate(extendedCollapsedSource, interpolatorFactory);
final double xScale = getXScale();
final double yScale = getYScale();
final double[] scale = { xScale, yScale };
final double[] shift = { 0.5 * xScale , 0.5 * yScale };
final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation(scale, shift);
final RealRandomAccessible<RealComposite<DoubleType>> stretchedCoefficients =
RealViews.transform(coefficients, scaleAndTranslation);
return stretchedCoefficients.realRandomAccess();
}
示例3: AbstractLUTGrid
import net.imglib2.realtransform.RealViews; //导入方法依赖的package包/类
public AbstractLUTGrid( final int numSourceDimensions, final int numTargetDimensions,
final RandomAccessibleInterval< DoubleType > lutArray, final double[] scale, final double[] shift )
{
super();
this.numSourceDimensions = numSourceDimensions;
this.numTargetDimensions = numTargetDimensions;
this.lutArray = lutArray;
// generate n-1 dimensional array that has local LUTs as columns
final CompositeIntervalView< DoubleType, RealComposite< DoubleType > > collapsedSource = Views.collapseReal( lutArray );
this.dimensions = new FinalInterval( collapsedSource );
this.nNonTransformedCoordinates = this.dimensions.numDimensions();
this.lutMaxIndex = ( int ) ( this.lutArray.dimension( this.nNonTransformedCoordinates ) ) - 1;
// generate scale transform to allow for generating interpolated
// high-res LUT from low-res LUT
this.scale = new double[ this.nNonTransformedCoordinates ];
this.shift = new double[ this.nNonTransformedCoordinates ];
copyAndFillIfNecessary( scale, this.scale );
copyAndFillIfNecessary( shift, this.shift );
final ScaleAndTranslation scaleAndShift = new ScaleAndTranslation( this.scale, this.shift );
final ExtendedRandomAccessibleInterval< RealComposite< DoubleType >, CompositeIntervalView< DoubleType, RealComposite< DoubleType > > > extendedCollapsedSource =
Views.extendBorder( collapsedSource );
this.coefficients = RealViews.transform( Views.interpolate( extendedCollapsedSource, this.interpolatorFactory ), scaleAndShift );
this.access = this.coefficients.realRandomAccess();
this.currentLut = this.access.get();
}
示例4: main
import net.imglib2.realtransform.RealViews; //导入方法依赖的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 );
}
示例5: xfmToView
import net.imglib2.realtransform.RealViews; //导入方法依赖的package包/类
public static <T extends RealType<T>> RealTransformRandomAccessible<T, InverseRealTransform> xfmToView(
InvertibleRealTransform xfm,
RandomAccessible<T> src,
InterpolatorFactory<T, RandomAccessible<T>> interpFactory)
{
RealRandomAccessible<T> interpolant = Views.interpolate(
src, interpFactory);
RealTransformRandomAccessible<T, InverseRealTransform> rv =
RealViews.transform( interpolant, xfm.inverse() );
return rv;
}
示例6: registerEdgelsOrient
import net.imglib2.realtransform.RealViews; //导入方法依赖的package包/类
public void registerEdgelsOrient( Edgel e, Edgel f, int i )
{
ImagePlusImgFactory<T> ipfactory = new ImagePlusImgFactory<T>();
Img<T> ePatch = ipfactory.create(patchSize, img.firstElement());
Img<T> fPatch = ipfactory.create(patchSize, img.firstElement());
computeCrackDepthNormalMask( e );
sampleImgByDepth( e, ePatch );
computeCrackDepthNormalMask( f );
sampleImgByDepth( f, fPatch );
ImgOps.writeFloat( ePatch,
String.format("%s/patchDepthSamp_test.tif", debugOutDir));
ImgOps.writeFloat( fPatch,
String.format("%s/patchDepthSamp_test_match.tif", debugOutDir));
Img<T> ePatch2 = ImgOps.collapseSum(ePatch);
Img<T> fPatch2 = ImgOps.collapseSum(fPatch);
int[] midPt = PatchTools.patchSizeToMidpt(patchSize);
int[] midPtPatch = ArrayUtil.subArray(
PatchTools.patchSizeToMidpt(patchSize),
0, ePatch2.numDimensions());
logger.debug(" end: " + (ePatch2.numDimensions() - 1));
logger.debug(" midPt: " + ArrayUtil.printArray(midPtPatch));
int zdim = midPtPatch.length - 1;
//
// IntervalView<T> ePatch2 = Views.hyperSlice( ePatch, zdim, midPt[zdim] );
// IntervalView<T> fPatch2 = Views.hyperSlice( fPatch, zdim, midPt[zdim] );
/** DEBUG WRITE TO FILE **/
long[] min = new long[ePatch2.numDimensions()];
ePatch2.min(min);
long[] max = new long[ePatch2.numDimensions()];
ePatch2.max(max);
IntervalIterator itvl = new IntervalIterator( min, max );
//
// logger.debug(" patchout min: " + ArrayUtil.printArray(min));
// logger.debug(" patchout max: " + ArrayUtil.printArray(max));
//
ImagePlusImg<T, ?> ePatch2out = ipfactory.create(itvl, img.firstElement());
ImgOps.copyInto(ePatch2, ePatch2out);
ImgOps.writeFloat( ePatch2out,
String.format("%s/patchDepthSamp_test_col.tif", debugOutDir));
ImagePlusImg<T, ?> fPatch2out = ipfactory.create(itvl, img.firstElement());
ImgOps.copyInto(fPatch2, fPatch2out);
ImgOps.writeFloat( fPatch2out,
String.format("%s/patchDepthSamp_test_col_match.tif", debugOutDir));
/** DEBUG WRITE TO FILE **/
// register
AffineTransform xfm = TransformTools.rotationPca(ePatch2, fPatch2, ArrayUtil.toDouble(midPtPatch));
logger.debug("xfm : \n" + TransformTools.printAffineTransform(xfm));
AffineTransform3D xfmPre = EdgelTools.edgelToXfm(f, midPt);
xfmPre.preConcatenate(xfm);
RealTransformRandomAccessible<T, InverseRealTransform> fPatch2Xfm = RealViews.transform(
Views.interpolate(img, new NLinearInterpolatorFactory<T>()),
xfmPre.inverse());
ImagePlusImg<T, ?> fPatch2Xfmout = ipfactory.create(itvl, img.firstElement());
ImgOps.copyInto(fPatch2Xfm, fPatch2Xfmout);
ImgOps.writeFloat( fPatch2Xfmout,
String.format("%s/patchDepthSamp_test_col_match_Xfm.tif", debugOutDir));
}