Search in sources :

Example 1 with IJGeom

use of org.vcell.imagej.helper.VCellHelper.IJGeom in project vcell by virtualcell.

the class SmallCR method createGeometry.

public static IJGeom createGeometry(ImgPlus<UnsignedByteType> nonZProjectedSegmentedGeom, int xIndex, int yIndex, int assumedZIndex, int xsize, int ysize, int zsize, HashMap<Integer, String> segmentedGeomValuesMapSubvolumeName) throws Exception {
    // Create byte array that defines vcell subvolumes ids (handles)
    byte[] vcellSubvolumeHandles = new byte[(int) Intervals.numElements(nonZProjectedSegmentedGeom)];
    Cursor<UnsignedByteType> nonZProjectedSegmentedGeomCursor = nonZProjectedSegmentedGeom.localizingCursor();
    while (nonZProjectedSegmentedGeomCursor.hasNext()) {
        UnsignedByteType segmentedGeomValue = (UnsignedByteType) nonZProjectedSegmentedGeomCursor.next();
        int currentZ = (assumedZIndex == -1 ? 0 : nonZProjectedSegmentedGeomCursor.getIntPosition(assumedZIndex));
        int currXYPixelIndex = nonZProjectedSegmentedGeomCursor.getIntPosition(yIndex) * xsize + nonZProjectedSegmentedGeomCursor.getIntPosition(xIndex);
        int currXYZPixelIndex = currXYPixelIndex + (assumedZIndex == -1 ? 0 : currentZ * (xsize * ysize));
        vcellSubvolumeHandles[currXYZPixelIndex] = (byte) segmentedGeomValue.get();
    }
    // Define new Geometry with domain equal to xyz pixel size for ease of use
    String[] subvolumeNames = segmentedGeomValuesMapSubvolumeName.values().toArray(new String[0]);
    Integer[] subvolumePixelValues = segmentedGeomValuesMapSubvolumeName.keySet().toArray(new Integer[0]);
    double[] origin = new double[] { 0, 0, 0 };
    double[] extent = new double[] { xsize, ysize, zsize };
    IJGeom ijGeom = new IJGeom(subvolumeNames, subvolumePixelValues, xsize, ysize, zsize, origin, extent, vcellSubvolumeHandles);
    return ijGeom;
}
Also used : UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) IJGeom(org.vcell.imagej.helper.VCellHelper.IJGeom)

Aggregations

UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 IJGeom (org.vcell.imagej.helper.VCellHelper.IJGeom)1