当前位置: 首页>>代码示例>>Java>>正文


Java Views.iterable方法代码示例

本文整理汇总了Java中net.imglib2.view.Views.iterable方法的典型用法代码示例。如果您正苦于以下问题:Java Views.iterable方法的具体用法?Java Views.iterable怎么用?Java Views.iterable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.imglib2.view.Views的用法示例。


在下文中一共展示了Views.iterable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVisibleIds

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public synchronized TLongHashSet getVisibleIds()
{
	final TLongHashSet visibleIds = new TLongHashSet();
	final int w = viewer.getWidth();
	final int h = viewer.getHeight();
	final AffineTransform3D viewerTransform = new AffineTransform3D();
	viewer.getState().getViewerTransform( viewerTransform );
	IntervalView< LabelMultisetType > screenLabels =
			Views.interval(
					Views.hyperSlice(
							RealViews.affine( labels, viewerTransform ), 2, 0 ),
					new FinalInterval( w, h ) );

	for ( final LabelMultisetType pixel : Views.iterable( screenLabels ) )
	{
		for ( final Entry< Label > entry : pixel.entrySet() )
				visibleIds.add( entry.getElement().id() );
	}

	return visibleIds;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:23,代码来源:LabelMultiSetIdPicker.java

示例2: assertRAIsEqual

import net.imglib2.view.Views; //导入方法依赖的package包/类
protected void assertRAIsEqual(final RandomAccessibleInterval<FloatType> rai1,
	final RandomAccessibleInterval<FloatType> rai2, final float delta)
{
	final IterableInterval<FloatType> rai1Iterator = Views.iterable(rai1);
	final IterableInterval<FloatType> rai2Iterator = Views.iterable(rai2);

	final Cursor<FloatType> c1 = rai1Iterator.cursor();
	final Cursor<FloatType> c2 = rai2Iterator.cursor();

	while (c1.hasNext()) {
		c1.fwd();
		c2.fwd();

		// assert that the inverse = the input within the error delta
		assertEquals(c1.get().getRealFloat(), c2.get().getRealFloat(), delta);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:18,代码来源:FFTTest.java

示例3: FirstIteration

import net.imglib2.view.Views; //导入方法依赖的package包/类
public FirstIteration(
		final ImagePortion portion,
		final RandomAccessibleInterval< FloatType > psi,
		final ArrayList< RandomAccessibleInterval< FloatType > > imgs )
{
	this.portion = portion;
	this.psi = psi;
	this.imgs = imgs;

	this.psiIterable = Views.iterable( psi );
	this.iterableImgs = new ArrayList< IterableInterval< FloatType > >();

	this.realSum = new RealSum();

	compatibleIteration = true;

	for ( final RandomAccessibleInterval< FloatType > img : imgs )
	{
		final IterableInterval< FloatType > imgIterable = Views.iterable( img );

		if ( !psiIterable.iterationOrder().equals( imgIterable.iterationOrder() ) )
			compatibleIteration = false;

		this.iterableImgs.add( imgIterable );
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:27,代码来源:FirstIteration.java

示例4: getImageMean

import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
 * Calculates the mean of an image.
 *
 * @param img The image to calculate the mean of
 * @return The mean of the image passed
 */
final public static <T extends RealType<T>> double getImageMean(
		final RandomAccessibleInterval<T> img )
{
	// Count all values using the RealSum class.
       // It prevents numerical instabilities when adding up millions of pixels
       RealSum realSum = new RealSum();
       long count = 0;

       for ( final T type : Views.iterable(img) )
       {
           realSum.add( type.getRealDouble() );
           ++count;
       }

       return realSum.getSum() / count;
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:23,代码来源:ImageStatistics.java

示例5: produceMeanBasedNoiseImage

import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
 * This method creates a noise image that has a specified mean.
 * Every pixel has a value uniformly distributed around mean with
 * the maximum spread specified.
 *
 * @return a new noise image
 * @throws MissingPreconditionException if specified means and spreads are not valid
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> produceMeanBasedNoiseImage(T type, int width,
		int height, double mean, double spread, double[] smoothingSigma, long seed) throws MissingPreconditionException {
	if (mean < spread || (mean + spread) > type.getMaxValue()) {
		throw new MissingPreconditionException("Mean must be larger than spread, and mean plus spread must be smaller than max of the type");
	}
	// create the new image
	ImgFactory<T> imgFactory = new ArrayImgFactory<T>();
	RandomAccessibleInterval<T> noiseImage = imgFactory.create( new int[] {width, height}, type); // "Noise image");

	Random r = new Random(seed);
	for (T value : Views.iterable(noiseImage)) {
		value.setReal( mean + ( (r.nextDouble() - 0.5) * spread ) );
	}

	return gaussianSmooth(noiseImage, smoothingSigma);
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:25,代码来源:TestImageAccessor.java

示例6: gaussianSmooth

import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
 * Gaussian Smooth of the input image using intermediate float format.
 * @param <T>
 * @param img
 * @param sigma
 * @return
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> gaussianSmooth(
		RandomAccessibleInterval<T> img, double[] sigma) {
	Interval interval = Views.iterable(img);

	ImgFactory<T> outputFactory = new ArrayImgFactory<T>();
	final long[] dim = new long[ img.numDimensions() ];
	img.dimensions(dim);
	RandomAccessibleInterval<T> output = outputFactory.create( dim,
			img.randomAccess().get().createVariable() );

	final long[] pos = new long[ img.numDimensions() ];
	Arrays.fill(pos, 0);
	Localizable origin = new Point(pos);

	ImgFactory<FloatType> tempFactory = new ArrayImgFactory<FloatType>();
	RandomAccessible<T> input = Views.extendMirrorSingle(img);
	Gauss.inFloat(sigma, input, interval, output, origin, tempFactory);

	return output;
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:28,代码来源:TestImageAccessor.java

示例7: pickBrightest

import net.imglib2.view.Views; //导入方法依赖的package包/类
public <T extends RealType<T>> RandomAccessibleInterval< T > pickBrightest(List<BasicViewDescription< ? >> vds,
												   List<RandomAccessibleInterval< T >> rais)
{
	
	if (rais.size() == 1)
		return rais.get( 0 );
	
	Double max = -Double.MAX_VALUE;
	int maxIdx = -1;
				
	for (int i = 0; i < rais.size(); i++){
		
		// a view is missing, do not take it into account
		if (rais.get( i ) == null)
			continue;
		
		IterableInterval< T > iterableImg = Views.iterable( rais.get( i ) );
		double mean = AdjustInput.sumImg( iterableImg ) / (double)iterableImg.size();
		if (mean > max)
		{
			max = mean;
			maxIdx = i;
		}
	}
	
	// all views were missing
	if (maxIdx < 0)
		return null;
	else
		return rais.get( maxIdx );			
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:32,代码来源:GroupedViewAggregator.java

示例8: getMean

import net.imglib2.view.Views; //导入方法依赖的package包/类
public static <T extends RealType<T>> double getMean(RandomAccessibleInterval<T> img)
{
	// TODO: if #pixels > ???? else RealSum
	// TODO: integral image?
	double sum = 0.0;
	long n = 0;
	for (T pix: Views.iterable(img)){
		sum += pix.getRealDouble();
		n++;
	}
	return sum/n;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:13,代码来源:PhaseCorrelation2Util.java

示例9: getVisibleIds

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public synchronized TLongHashSet getVisibleIds()
{
	final TLongHashSet visibleIds = new TLongHashSet();
	final int w = viewer.getWidth();
	final int h = viewer.getHeight();
	final AffineTransform3D viewerTransform = new AffineTransform3D();
	viewer.getState().getViewerTransform( viewerTransform );
	final IntervalView< Pair< LabelMultisetType, LongType > > screenLabels =
			Views.interval(
					Views.hyperSlice(
							RealViews.affine( labels, viewerTransform ), 2, 0 ),
					new FinalInterval( w, h ) );

	for ( final Pair< LabelMultisetType, LongType > pixel : Views.iterable( screenLabels ) )
	{
		final long b = pixel.getB().get();
		if ( b == Label.TRANSPARENT )
		{
			final LabelMultisetType a = pixel.getA();
			for ( final Entry< Label > entry : a.entrySet() )
				visibleIds.add( entry.getElement().id() );
		}
		else
			visibleIds.add( b );
	}

	return visibleIds;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:30,代码来源:PairLabelMultiSetLongIdPicker.java

示例10: act

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public < T extends RealType< T > > void act(
		final int iteration,
		final RandomAccessibleInterval< T > matrix,
		final RandomAccessibleInterval< T > scaledMatrix,
		final double[] lut,
		final int[] permutation,
		final int[] inversePermutation,
		final double[] multipliers,
		final RandomAccessibleInterval< double[] > estimatedFits )
{

	if ( estimatedFits == null )
		return;
	try
	{
		final String path = fileDir( iteration );
		createParentDirectory( path );
		final IterableInterval< double[] > iterable = Views.iterable( estimatedFits );
		write( new IndexedIterable<>( separator, new ArrayIterable( iterable ) ), path );
	}
	catch ( final IOException e )
	{
		// catch exceptions?
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:30,代码来源:CorrelationFitVisitor.java

示例11: main

import net.imglib2.view.Views; //导入方法依赖的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 );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:37,代码来源:Block.java

示例12: createMask

import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
 * Create a new mask image with a defined size and preset content.
 */
public static RandomAccessibleInterval<BitType> createMask(long[] dim, boolean val) {
	RandomAccessibleInterval<BitType> mask = createMask(dim);
	
	for (BitType t : Views.iterable(mask))
		t.set(val);
	
	return mask;
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:12,代码来源:MaskFactory.java

示例13: project

import net.imglib2.view.Views; //导入方法依赖的package包/类
private RandomAccessibleInterval<T> project(
	final RandomAccessibleInterval<T> image)
{
	if (image.numDimensions() < 2) {
		throw new IllegalArgumentException("Dimensionality too small: " + //
			image.numDimensions());
	}

	final IterableInterval<T> input = Views.iterable(image);
	final T type = input.firstElement(); // e.g. unsigned 8-bit
	final long xLen = image.dimension(0);
	final long yLen = image.dimension(1);

	// initialize output image with minimum value of the pixel type
	final long[] outputDims = { xLen, yLen };
	final Img<T> output = new ArrayImgFactory<T>().create(outputDims, type);
	for (final T sample : output) {
		sample.setReal(type.getMinValue());
	}

	// loop over the input image, performing the max projection
	final Cursor<T> inPos = input.localizingCursor();
	final RandomAccess<T> outPos = output.randomAccess();
	while (inPos.hasNext()) {
		final T inPix = inPos.next();
		final long xPos = inPos.getLongPosition(0);
		final long yPos = inPos.getLongPosition(1);
		outPos.setPosition(xPos, 0);
		outPos.setPosition(yPos, 1);
		final T outPix = outPos.get();
		if (outPix.compareTo(inPix) < 0) {
			outPix.set(inPix);
		}
	}
	return output;
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:37,代码来源:Coloc_2.java

示例14: getImageIntegral

import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
 * Calculates the integral of the pixel values of an image.
 *
 * @param img The image to calculate the integral of
 * @return The pixel values integral of the image passed
 */
final public static <T extends RealType<T>> double getImageIntegral(
		final RandomAccessibleInterval<T> img )
{
	final RealSum sum = new RealSum();

	for ( final T type : Views.iterable(img) )
		sum.add( type.getRealDouble() );

	return sum.getSum();
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:17,代码来源:ImageStatistics.java

示例15: computeDataMinMax

import net.imglib2.view.Views; //导入方法依赖的package包/类
private void computeDataMinMax(
	final RandomAccessibleInterval<? extends RealType<?>> img)
{
	// FIXME: Reconcile this with DefaultDatasetView.autoscale(int). There is
	// no reason to hardcode the usage of ComputeMinMax twice. Rather, there
	// should be a single entry point for obtain the channel min/maxes from
	// the metadata, and if they aren't there, then compute them. Probably
	// Dataset (not DatasetView) is a good place for it, because it is metadata
	// independent of the visualization settings.

	DataRange range = autoscaleService.getDefaultRandomAccessRange(img);
	dataMin = range.getMin();
	dataMax = range.getMax();

	final MutableModuleItem<Double> minItem =
		getInfo().getMutableInput("min", Double.class);
	minItem.setSoftMinimum(dataMin);
	minItem.setSoftMaximum(dataMax);
	final MutableModuleItem<Double> maxItem =
		getInfo().getMutableInput("max", Double.class);
	maxItem.setSoftMinimum(dataMin);
	maxItem.setSoftMaximum(dataMax);

	// System.out.println("IN HERE!!!!!!");
	// System.out.println(" dataMin = " + dataMin);
	// System.out.println(" dataMax = " + dataMax);
	@SuppressWarnings({ "unchecked", "rawtypes" })
	Iterable<T> iterable =
		Views
			.iterable((RandomAccessibleInterval<T>) (RandomAccessibleInterval) img);
	BinMapper1d<T> mapper =
		new Real1dBinMapper<T>(dataMin, dataMax, 256, false);
	Histogram1d<T> histogram = new Histogram1d<T>(iterable, mapper);
	if (bundle == null) {
		bundle = new HistogramBundle(histogram);
	}
	else {
		bundle.setHistogram(0, histogram);
	}
	bundle.setDataMinMax(dataMin, dataMax);
	// bundle.setLineSlopeIntercept(1, 0);
	log().debug(
		"computeDataMinMax: dataMin=" + dataMin + ", dataMax=" + dataMax);
	// force a widget refresh to see new Hist (and also fill min and max fields)
	// NOPE. HistBundle is unchanged. Only internals are. So no
	// refresh called. Note that I changed InteractiveCommand::update() to
	// always setValue() and still this did not work. !!!! Huh?
	// update(getInfo().getMutableInput("bundle", HistogramBundle.class),
	// bundle);
	// NOPE
	// getInfo().getInput("bundle", HistogramBundle.class).setValue(this,
	// bundle);
	// NOPE
	// getInfo().setVisible(false);
	// getInfo().setVisible(true);
	// NOPE
	// getInfo().getMutableInput("bundle",HistogramBundle.class).initialize(this);
	// NOPE
	// getInfo().getMutableInput("bundle",HistogramBundle.class).callback(this);
}
 
开发者ID:bnanes,项目名称:slideset,代码行数:61,代码来源:BrightnessContrastRoi.java


注:本文中的net.imglib2.view.Views.iterable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。