Search in sources :

Example 6 with FinalInterval

use of net.imglib2.FinalInterval in project vcell by virtualcell.

the class LargestRegionSlice method run.

@Override
public void run() {
    int maxArea = 0;
    int zOfMaxArea = 0;
    for (int z = 0; z < data.dimension(2); z++) {
        FinalInterval interval = Intervals.createMinMax(0, 0, z, data.dimension(0) - 1, data.dimension(1) - 1, z);
        RandomAccessibleInterval<BitType> croppedRAI = ops.transform().crop(data, interval);
        IterableInterval<BitType> croppedII = Views.iterable(croppedRAI);
        Cursor<BitType> cursor = croppedII.cursor();
        int area = 0;
        while (cursor.hasNext()) {
            if (cursor.next().get()) {
                area++;
            }
        }
        if (area > maxArea) {
            maxArea = area;
            zOfMaxArea = z;
        }
    }
    FinalInterval interval = Intervals.createMinMax(0, 0, zOfMaxArea, data.dimension(0) - 1, data.dimension(1) - 1, zOfMaxArea);
    output = ops.transform().crop(data, interval);
}
Also used : BitType(net.imglib2.type.logic.BitType) FinalInterval(net.imglib2.FinalInterval)

Aggregations

FinalInterval (net.imglib2.FinalInterval)6 BitType (net.imglib2.type.logic.BitType)3 File (java.io.File)2 Dataset (net.imagej.Dataset)2 ImgPlus (net.imagej.ImgPlus)2 Img (net.imglib2.img.Img)2 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Scanner (java.util.Scanner)1 RandomAccess (net.imglib2.RandomAccess)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 NLinearInterpolatorFactory (net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory)1 RealType (net.imglib2.type.numeric.RealType)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 DoubleType (net.imglib2.type.numeric.real.DoubleType)1 FloatType (net.imglib2.type.numeric.real.FloatType)1 RealSum (net.imglib2.util.RealSum)1 ValuePair (net.imglib2.util.ValuePair)1 IntervalView (net.imglib2.view.IntervalView)1