net.imglib2.RandomAccessibleInterval Java Examples
The following examples show how to use
net.imglib2.RandomAccessibleInterval.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiICQ.java From Colocalisation_Analysis with GNU General Public License v3.0 | 6 votes |
@Override public void execute(DataContainer<T> container) throws MissingPreconditionException { double mean1 = container.getMeanCh1(); double mean2 = container.getMeanCh2(); // get the 2 images for the calculation of Li's ICQ RandomAccessible<T> img1 = container.getSourceImage1(); RandomAccessible<T> img2 = container.getSourceImage2(); RandomAccessibleInterval<BitType> mask = container.getMask(); TwinCursor<T> cursor = new TwinCursor<T>(img1.randomAccess(), img2.randomAccess(), Views.iterable(mask).localizingCursor()); // calculate ICQ value icqValue = calculateLisICQ(cursor, mean1, mean2); }
Example #2
Source File: PermuteViewTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testIntervalPermuteCoordinates() { Img<DoubleType> img = ArrayImgs.doubles(2, 2); Cursor<DoubleType> c = img.cursor(); MersenneTwisterFast r = new MersenneTwisterFast(SEED); while (c.hasNext()) { c.next().set(r.nextDouble()); } IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[]{0, 1}); Cursor<DoubleType> e = expected.cursor(); RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[]{0, 1}); RandomAccess<DoubleType> actualRA = actual.randomAccess(); while (e.hasNext()) { e.next(); actualRA.setPosition(e); assertEquals(e.get().get(), actualRA.get().get(), 1e-10); } assertTrue(Intervals.equals(expected, actual)); }
Example #3
Source File: WrappedIntegralImg.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Override public RandomAccessibleInterval<DoubleType> calculate( final RandomAccessibleInterval<I> input) { // Create IntegralImg from input integralImg = new IntegralImg<>(input, new DoubleType(), new RealDoubleConverter<I>()); // integralImg will be larger by one pixel in each dimension than input // due // to the computation of the integral image RandomAccessibleInterval<DoubleType> img = null; if (integralImg.process()) { img = integralImg.getResult(); } return img; }
Example #4
Source File: MTKT.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Double calculate(final RandomAccessibleInterval<T> image1, final RandomAccessibleInterval<U> image2) { // check image sizes // TODO: Add these checks to conforms(). if (!(Intervals.equalDimensions(image1, image2))) { throw new IllegalArgumentException("Image dimensions do not match"); } final long n1 = Intervals.numElements(image1); if (n1 > Integer.MAX_VALUE) { throw new IllegalArgumentException("Image dimensions too large: " + n1); } final int n = (int) n1; // compute thresholds final double thresh1 = threshold(image1); final double thresh2 = threshold(image2); double[][] rank = rankTransformation(image1, image2, thresh1, thresh2, n, seed); double maxtau = calculateMaxKendallTau(rank, thresh1, thresh2, n); return maxtau; }
Example #5
Source File: ClearingCompositeProjector.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public VolatileProjector createAccumulateProjector( final ArrayList<VolatileProjector> sourceProjectors, final ArrayList<Source<?>> sources, final ArrayList<? extends RandomAccessible<? extends A>> sourceScreenImages, final RandomAccessibleInterval<A> targetScreenImage, final int numThreads, final ExecutorService executorService) { final ClearingCompositeProjector<A> projector = new ClearingCompositeProjector<>( sourceProjectors, sourceScreenImages, targetScreenImage, clearValue, numThreads, executorService ); final ArrayList<Composite<A, A>> activeComposites = new ArrayList<>(); for (final Source<?> activeSource : sources) activeComposites.add(composites.get(activeSource)); projector.setComposites(activeComposites); return projector; }
Example #6
Source File: FloodFill.java From paintera with GNU General Public License v2.0 | 6 votes |
private static <T extends IntegerType<T>> void fillPrimitiveType( final RandomAccessibleInterval<T> input, final RandomAccessible<UnsignedLongType> output, final Localizable seed, final long seedLabel, final FragmentSegmentAssignment assignment) { final T extension = Util.getTypeFromInterval(input).createVariable(); extension.setInteger(Label.OUTSIDE); net.imglib2.algorithm.fill.FloodFill.fill( Views.extendValue(input, extension), output, seed, new UnsignedLongType(1), new DiamondShape(1), makePredicate(seedLabel, assignment) ); }
Example #7
Source File: Maps.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
public static <I1, I2, O> void map(final IterableInterval<I1> a, final RandomAccessibleInterval<I2> b, final RandomAccessibleInterval<O> c, final BinaryComputerOp<I1, I2, O> op, final long startIndex, final long stepSize, final long numSteps) { if (numSteps <= 0) return; final Cursor<I1> aCursor = a.localizingCursor(); final RandomAccess<I2> bAccess = b.randomAccess(); final RandomAccess<O> cAccess = c.randomAccess(); for (long ctr = 0; ctr < numSteps; ctr++) { aCursor.jumpFwd(ctr == 0 ? startIndex + 1 : stepSize); bAccess.setPosition(aCursor); cAccess.setPosition(aCursor); op.compute(aCursor.get(), bAccess.get(), cAccess.get()); } }
Example #8
Source File: MTKT.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
static <T extends RealType<T>, U extends RealType<U>> double[][] rankTransformation(final RandomAccessibleInterval<T> image1, final RandomAccessibleInterval<U> image2, final double thres1, final double thres2, final int n, long seed) { // FIRST... final int[] rankIndex1 = rankSamples(image1, seed); final int[] rankIndex2 = rankSamples(image2, seed); IntArray validIndex = new IntArray(new int[n]); validIndex.setSize(0); for (int i = 0; i < n; i++) { if(rankIndex1[i] >= thres1 && rankIndex2[i] >= thres2) { validIndex.addValue(i); } } int rn = validIndex.size(); double[][] finalRanks = new double[rn][2]; for (int i = 0; i < rn; i++) { final int index = validIndex.getValue(i); finalRanks[i][0] = Math.floor(rankIndex1[index]); finalRanks[i][1] = Math.floor(rankIndex2[index]); } return finalRanks; }
Example #9
Source File: MTKTTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testMTKTpValueNone() { double[][] values = new double[10][2]; double[] values1 = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; double[] values2 = { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 }; for (int i = 0; i < 4; i++) { values[i][0] = values1[i]; values[i][1] = values2[i]; } Img<DoubleType> vImage1 = ArrayImgs.doubles(values1, values1.length); Img<DoubleType> vImage2 = ArrayImgs.doubles(values2, values2.length); BinaryFunctionOp<RandomAccessibleInterval<DoubleType>, RandomAccessibleInterval<DoubleType>, Double> op = Functions.binary(ops, MTKT.class, Double.class, vImage1, vImage2); PValueResult value = (PValueResult) ops.run(Ops.Coloc.PValue.class, new PValueResult(), vImage1, vImage2, op, 5); assertEquals(0.0, value.getPValue(), 0.0); }
Example #10
Source File: LegacyMicroManagerImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@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; } }
Example #11
Source File: RAIToPNGNotebookConverter.java From scijava-jupyter-kernel with Apache License 2.0 | 5 votes |
@Override public PNGImageNotebookOutput convert(Object object) { RandomAccessibleInterval<T> source = (RandomAccessibleInterval<T>) object; // NB: Assume <=3 samples in the 3rd dimension means channels. Of course, // we have no metadata with a vanilla RAI, but this is a best guess; // 3rd dimensions with >3 samples are probably something like Z or time. final int cAxis = source.numDimensions() > 2 && source.dimension(2) <= 3 ? 2 : -1; String base64Image = (String) ijnb.RAIToPNG(source, 0, 1, cAxis, ValueScaling.AUTO); return new PNGImageNotebookOutput(base64Image); }
Example #12
Source File: LabelSourceState.java From paintera with GNU General Public License v2.0 | 5 votes |
public static <D extends IntegerType<D> & NativeType<D>, T extends Volatile<D> & IntegerType<T>> LabelSourceState<D, T> simpleSourceFromSingleRAI( final RandomAccessibleInterval<D> data, final double[] resolution, final double[] offset, final Invalidate<Long> invalidate, final long maxId, final String name, final Group meshesGroup, final ObjectProperty<ViewFrustum> viewFrustumProperty, final ObjectProperty<AffineTransform3D> eyeToWorldTransformProperty, final ExecutorService meshManagerExecutors, final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> meshWorkersExecutors) { return simpleSourceFromSingleRAI( data, resolution, offset, invalidate, maxId, name, new LabelBlockLookupNoBlocks(), meshesGroup, viewFrustumProperty, eyeToWorldTransformProperty, meshManagerExecutors, meshWorkersExecutors); }
Example #13
Source File: ImageNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** Executes the "distancetransform" operation on the given arguments. */ @OpMethod(ops = { net.imagej.ops.image.distancetransform.DefaultDistanceTransform.class, net.imagej.ops.image.distancetransform.DistanceTransform2D.class, net.imagej.ops.image.distancetransform.DistanceTransform3D.class }) public <B extends BooleanType<B>, T extends RealType<T>> RandomAccessibleInterval<T> distancetransform( final RandomAccessibleInterval<B> in) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<T> result = (RandomAccessibleInterval<T>) ops().run(Ops.Image.DistanceTransform.class, in); return result; }
Example #14
Source File: FilterNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** Executes the "convolve" operation on the given arguments. */ @OpMethod(ops = { net.imagej.ops.filter.convolve.ConvolveNaiveF.class, net.imagej.ops.filter.convolve.PadAndConvolveFFTF.class }) public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>> RandomAccessibleInterval<O> convolve(final RandomAccessibleInterval<I> in, final RandomAccessibleInterval<K> kernel, final OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obf, final O outType) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<O> result = (RandomAccessibleInterval<O>) ops().run(Ops.Filter.Convolve.class, in, kernel, obf, outType); return result; }
Example #15
Source File: FilterNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@OpMethod(op = net.imagej.ops.filter.sobel.SobelRAI.class) public <T extends RealType<T>> RandomAccessibleInterval<T> sobel( final RandomAccessibleInterval<T> out, final RandomAccessibleInterval<T> in) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<T> result = (RandomAccessibleInterval<T>) ops().run( net.imagej.ops.filter.sobel.SobelRAI.class, out, in); return result; }
Example #16
Source File: CreateNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** * Convenience wrapper to create an {@link Img} of type {@link ComplexFloatType} * with an isotropic Gabor kernel. */ @OpMethod( op = net.imagej.ops.create.kernelGabor.CreateKernelGaborIsotropic.class) public RandomAccessibleInterval<ComplexFloatType> kernelGaborComplexFloat(final Double sigma, final double... period) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<ComplexFloatType> result = (RandomAccessibleInterval<ComplexFloatType>) ops().run( net.imagej.ops.create.kernelGabor.CreateKernelGaborIsotropic.class, sigma, period, new ComplexFloatType()); return result; }
Example #17
Source File: PadAndConvolveFFT.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** * create a convolve filter computer */ @Override public BinaryComputerOp<RandomAccessibleInterval<I>, RandomAccessibleInterval<K>, RandomAccessibleInterval<O>> createFilterComputer(RandomAccessibleInterval<I> paddedInput, RandomAccessibleInterval<K> paddedKernel, RandomAccessibleInterval<C> fftImg, RandomAccessibleInterval<C> fftKernel, RandomAccessibleInterval<O> output) { return Computers.binary(ops(), ConvolveFFTC.class, output, paddedInput, paddedKernel, fftImg, fftKernel); }
Example #18
Source File: GroupedViewAggregator.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
public <T extends RealType<T>> Map<BasicViewDescription<?>, RandomAccessibleInterval<T>> aggregate( Map<BasicViewDescription< ? >, RandomAccessibleInterval<T>> input) { Map<BasicViewDescription<?>, RandomAccessibleInterval<T>> res = new HashMap<>(); if (actionType == ActionType.PICK_SPECIFIC) res = pickSpecific(input); else if (actionType == ActionType.PICK_BRIGHTEST) res = pickBrightest(input); else //if (actionType == ActionType.AVERAGE) res = average(input); return res; }
Example #19
Source File: ThresholdNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@OpMethod( op = net.imagej.ops.threshold.localSauvola.LocalSauvolaThresholdIntegral.class) public <T extends RealType<T>> IterableInterval<BitType> localSauvolaThreshold(final IterableInterval<BitType> out, final RandomAccessibleInterval<T> in, final RectangleShape shape, final OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBounds, final double k) { @SuppressWarnings("unchecked") final IterableInterval<BitType> result = (IterableInterval<BitType>) ops() .run(net.imagej.ops.Ops.Threshold.LocalSauvolaThreshold.class, out, in, shape, outOfBounds, k); return result; }
Example #20
Source File: FilterNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@OpMethod(op = net.imagej.ops.filter.ifft.IFFTMethodsOpI.class) public <C extends ComplexType<C>> RandomAccessibleInterval<C> ifft( final RandomAccessibleInterval<C> arg) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<C> result = (RandomAccessibleInterval<C>) ops().run(Ops.Filter.IFFT.class, arg); return result; }
Example #21
Source File: ThresholdNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@OpMethod( op = net.imagej.ops.threshold.ApplyThresholdMethodLocal.LocalMinErrorThreshold.class) public <T extends RealType<T>, B extends BooleanType<B>> IterableInterval<B> minError(final IterableInterval<B> out, final RandomAccessibleInterval<T> in, final Shape shape) { @SuppressWarnings("unchecked") final IterableInterval<B> result = (IterableInterval<B>) ops().run( net.imagej.ops.threshold.ApplyThresholdMethodLocal.LocalMinErrorThreshold.class, out, in, shape); return result; }
Example #22
Source File: FilterNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** Executes the "fft" operation on the given arguments. */ @OpMethod(op = net.imagej.ops.filter.fft.FFTMethodsOpF.class) public <T extends RealType<T>, I extends RandomAccessibleInterval<T>, C extends ComplexType<C>, O extends RandomAccessibleInterval<C>> RandomAccessibleInterval<C> fft(final RandomAccessibleInterval<T> in, final long... borderSize) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<C> result = (RandomAccessibleInterval<C>) ops().run(Ops.Filter.FFT.class, in, borderSize); return result; }
Example #23
Source File: WatershedSeededTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
private void assertResults(final RandomAccessibleInterval<FloatType> in, final ImgLabeling<Integer, IntType> out, final ImgLabeling<Integer, IntType> seeds, final RandomAccessibleInterval<BitType> mask, final boolean withWatersheds, final boolean smallMask) { final Cursor<LabelingType<Integer>> curOut = out.cursor(); final RandomAccess<BitType> raMask = mask.randomAccess(); while (curOut.hasNext()) { curOut.fwd(); raMask.setPosition(curOut); if (raMask.get().get()) { assertEquals(1, curOut.get().size()); } else { assertEquals(true, curOut.get().isEmpty()); } } // Sample the output image based on the mask IterableRegion<BitType> regions = Regions.iterable(mask); // count labels Set<Integer> labelSet = new HashSet<>(); for (LabelingType<Integer> pixel : Regions.sample(regions, out)) { labelSet.addAll(pixel); } // assert equals assertEquals(in.numDimensions(), out.numDimensions()); assertEquals(in.dimension(0), out.dimension(0)); assertEquals(in.dimension(1), out.dimension(1)); assertEquals(3 + (withWatersheds ? 1 : 0), labelSet.size() + (smallMask ? 1 : 0)); }
Example #24
Source File: LabelingNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@OpMethod(op = net.imagej.ops.labeling.cca.DefaultCCA.class) public <T extends IntegerType<T>, L, I extends IntegerType<I>> ImgLabeling<L, I> cca(final ImgLabeling<L, I> out, final RandomAccessibleInterval<T> in, final StructuringElement element) { @SuppressWarnings("unchecked") final ImgLabeling<L, I> result = (ImgLabeling<L, I>) ops().run( net.imagej.ops.Ops.Labeling.CCA.class, out, in, element); return result; }
Example #25
Source File: AbstractFFTFilterC.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
protected RandomAccessibleInterval<C> getFFTInput() { if (fftType == null) { fftType = (ComplexType<C>) ops().create().nativeType( ComplexFloatType.class); } return fftInput; }
Example #26
Source File: TransformNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** * Invert the d-axis while preserving interval bounds. * * @param input the source * @param d the axis to invert */ @OpMethod( op = net.imagej.ops.transform.invertAxisView.IntervalInvertAxisView.class) public <T> IntervalView<T> invertAxisView( final RandomAccessibleInterval<T> input, final int d) { return (IntervalView<T>) ops().run(Ops.Transform.InvertAxisView.class, input, d); }
Example #27
Source File: DeconvolveNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Deprecated public <I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>> RandomAccessibleInterval<O> richardsonLucyTV( final RandomAccessibleInterval<I> in, final RandomAccessibleInterval<K> kernel, final long[] borderSize, final OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput, final OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel, final O outType, final C fftType, final int maxIterations, final boolean nonCirculant, final boolean accelerate, final float regularizationFactor) { return richardsonLucyTV(create(in, outType), in, kernel, borderSize, obfInput, obfKernel, outType, fftType, maxIterations, nonCirculant, accelerate, regularizationFactor); }
Example #28
Source File: NonCirculantNormalizationFactor.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void initialize() { create = (UnaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class, Img.class, Dimensions.class, Util.getTypeFromInterval(out())); correlater = (BinaryComputerOp) Computers.binary(ops(), CorrelateFFTC.class, RandomAccessibleInterval.class, RandomAccessibleInterval.class, RandomAccessibleInterval.class, fftInput, fftKernel, true, false); divide = new DivideHandleZeroMap<>(); divide.setEnvironment(ops()); divide.initialize(); }
Example #29
Source File: CreateNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** * Convenience wrapper to create an {@link Img} of type {@link DoubleType} * with an isotropic Gabor kernel. */ @OpMethod( op = net.imagej.ops.create.kernelGabor.CreateKernelGaborIsotropicDoubleType.class) public RandomAccessibleInterval<DoubleType> kernelGaborDouble(final Double sigma, final double... period) { @SuppressWarnings("unchecked") final RandomAccessibleInterval<DoubleType> result = (RandomAccessibleInterval<DoubleType>) ops().run( net.imagej.ops.create.kernelGabor.CreateKernelGaborIsotropicDoubleType.class, sigma, period); return result; }
Example #30
Source File: MorphologyNamespace.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@OpMethod(op = net.imagej.ops.morphology.open.ListOpen.class) public <T extends RealType<T>> IterableInterval<T> open( final RandomAccessibleInterval<T> in1, final List<Shape> in2) { @SuppressWarnings("unchecked") final IterableInterval<T> result = (IterableInterval<T>) ops().run( net.imagej.ops.Ops.Morphology.Open.class, in1, in2); return result; }