Java Code Examples for net.imglib2.RealInterval#numDimensions()
The following examples show how to use
net.imglib2.RealInterval#numDimensions() .
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: TransformTools.java From BigStitcher with GNU General Public License v2.0 | 6 votes |
public static FinalRealInterval applyTranslation(RealInterval img, TranslationGet translation, boolean[] ignoreDims){ // get number of dimensions we actually use int n = 0; for (int d = 0; d < ignoreDims.length; ++d) if (!ignoreDims[d]) n++; final double [] min = new double [n]; final double [] max = new double [n]; int i2 = 0; for (int i = 0; i< img.numDimensions();++i) { if (!ignoreDims[i]) { min[i2] = img.realMin(i) + translation.getTranslation(i); max[i2] = img.realMax(i) + translation.getTranslation(i); i2++; } } return new FinalRealInterval(min, max); }
Example 2
Source File: TransformTools.java From BigStitcher with GNU General Public License v2.0 | 6 votes |
/** * create an integer interval from real interval, being conservatie on the size * (min is ceiled, max is floored) * @param overlap real input * @return interger interval, with mins ceiled and maxs floored */ public static FinalInterval getLocalRasterOverlap(RealInterval overlap) { final int n = overlap.numDimensions(); final long [] min = new long [n]; final long [] max = new long [n]; for (int i = 0; i< n; i++) { // round down errors when it is exactly 0.5, if we do not do this we end up with two intervals // of different size, e.g.: // if the first interval starts at 139.5 going to 199, the second one at 0.0 going to 59.5 // then the rastered 1st would go from round(139.5)=140 + 1 = 141 -to- round(199)=199 - 1 = 198, dim=58 // and the rastered 2nd would go from round(0.0)=0 + 1 = 1 -to- round(59.5)=60 - 1 = 59, dim=59 min[i] = Math.round((overlap.realMin(i) - 0.0001 )) + 1; max[i] = Math.round((overlap.realMax(i) + 0.0001 )) - 1; } return new FinalInterval(min, max); }
Example 3
Source File: TransformTools.java From BigStitcher with GNU General Public License v2.0 | 6 votes |
public static FinalRealInterval getOverlap(final RealInterval img1, final RealInterval img2){ final int n = img1.numDimensions(); final double [] min = new double [n]; final double [] max = new double [n]; for (int i = 0; i< n; i++) { min[i] = Math.max(img1.realMin(i), img2.realMin(i)); max[i] = Math.min(img1.realMax(i), img2.realMax(i)); // intervals do not overlap if ( max[i] < min [i]) return null; } return new FinalRealInterval(min, max); }
Example 4
Source File: MeshGeneratorJobManager.java From paintera with GNU General Public License v2.0 | 5 votes |
private Node createBlockShape(final ShapeKey<T> key) { final Interval keyInterval = key.interval(); final double[] worldMin = new double[3], worldMax = new double[3]; Arrays.setAll(worldMin, d -> keyInterval.min(d)); Arrays.setAll(worldMax, d -> keyInterval.min(d) + keyInterval.dimension(d)); unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMin, worldMin); unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMax, worldMax); final RealInterval blockWorldInterval = new FinalRealInterval(worldMin, worldMax); final double[] blockWorldSize = new double[blockWorldInterval.numDimensions()]; Arrays.setAll(blockWorldSize, d -> blockWorldInterval.realMax(d) - blockWorldInterval.realMin(d)); // the standard Box primitive is made up of triangles, so the unwanted diagonals are visible when using DrawMode.Line // final Box box = new Box( // blockWorldSize[0], // blockWorldSize[1], // blockWorldSize[2] // ); final PolygonMeshView box = new PolygonMeshView(Meshes.createQuadrilateralMesh( (float) blockWorldSize[0], (float) blockWorldSize[1], (float) blockWorldSize[2] )); final double[] blockWorldTranslation = new double[blockWorldInterval.numDimensions()]; Arrays.setAll(blockWorldTranslation, d -> blockWorldInterval.realMin(d) + blockWorldSize[d] * 0.5); box.setTranslateX(blockWorldTranslation[0]); box.setTranslateY(blockWorldTranslation[1]); box.setTranslateZ(blockWorldTranslation[2]); final PhongMaterial material = Meshes.painteraPhongMaterial(); box.setCullFace(CullFace.NONE); box.setMaterial(material); box.setDrawMode(DrawMode.LINE); return box; }
Example 5
Source File: TransformTools.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
/** * get overlap in local image coordinates (assuming min = (0,0,..)) * @param img image interval (global coordinates) * @param overlap overlap interval (global coordinates) * @return overlap interval in local coordinates */ public static FinalRealInterval getLocalOverlap(RealInterval img, RealInterval overlap){ final int n = img.numDimensions(); final double [] min = new double [n]; final double [] max = new double [n]; for (int i = 0; i< n; i++) { min[i] = Math.max(0, overlap.realMin(i) - img.realMin(i)) ; max[i] = Math.max(0, overlap.realMax(i) - img.realMin(i)); } return new FinalRealInterval(min, max); }