Java Code Examples for net.imglib2.Localizable#getLongPosition()
The following examples show how to use
net.imglib2.Localizable#getLongPosition() .
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: ShuffledView.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
private static <T> RandomAccessibleInterval<T> cropAt( final RandomAccessibleInterval<T> image, final int[] blockSize, final Localizable offset) { final int numDims = image.numDimensions(); final long[] minsize = new long[numDims * 2]; for (int d = 0; d < numDims; d++) { minsize[d] = offset.getLongPosition(d); final long shaveSize = image.dimension(d) % blockSize[d]; minsize[numDims + d] = image.dimension(d) - shaveSize; } return Views.interval(image, FinalInterval.createMinSize(minsize)); }
Example 2
Source File: PhaseCorrelation2Util.java From BigStitcher with GNU General Public License v2.0 | 4 votes |
public static Pair<Interval, Interval> getOverlapIntervals(Dimensions img1, Dimensions img2, Localizable shift){ final int numDimensions = img1.numDimensions(); final long[] offsetImage1 = new long[ numDimensions ]; final long[] offsetImage2 = new long[ numDimensions ]; final long[] maxImage1 = new long[ numDimensions ]; final long[] maxImage2 = new long[ numDimensions ]; long overlapSize; for ( int d = 0; d < numDimensions; ++d ) { if ( shift.getLongPosition(d) >= 0 ) { // two possiblities // // shift=start end // | | // A: Image 1 ------------------------------ // Image 2 ---------------------------------- // // shift=start end // | | // B: Image 1 ------------------------------ // Image 2 ------------------- // they are not overlapping ( this might happen due to fft zeropadding and extension ) if ( shift.getLongPosition(d) >= img1.dimension( d ) ) { return null; } offsetImage1[ d ] = shift.getLongPosition(d); offsetImage2[ d ] = 0; overlapSize = Math.min( img1.dimension( d ) - shift.getLongPosition(d), img2.dimension( d ) ); maxImage1[ d ] = offsetImage1[d] + overlapSize -1; maxImage2[ d ] = offsetImage2[d] + overlapSize -1; } else { // two possiblities // // shift start end // | | ` | // A: Image 1 ------------------------------ // Image 2 ------------------------------ // // shift start end // | | | // B: Image 1 ------------ // Image 2 ------------------- // they are not overlapping ( this might happen due to fft zeropadding and extension if ( shift.getLongPosition(d) <= -img2.dimension( d ) ) { return null; } offsetImage1[ d ] = 0; offsetImage2[ d ] = -shift.getLongPosition(d); overlapSize = Math.min( img2.dimension( d ) + shift.getLongPosition(d), img1.dimension( d ) ); maxImage1[ d ] = offsetImage1[d] + overlapSize -1; maxImage2[ d ] = offsetImage2[d] + overlapSize -1; } } FinalInterval img1Interval = new FinalInterval(offsetImage1, maxImage1); FinalInterval img2Interval = new FinalInterval(offsetImage2, maxImage2); Pair<Interval, Interval> res = new ValuePair<Interval, Interval>(img1Interval, img2Interval); return res; }