@Override public long map( final T value ) { final long val = value.getIntegerLong(); long pos; if ( val >= minVal && val <= maxVal ) { pos = val - minVal; if ( tailBins ) pos++; } else if ( tailBins ) { if ( val < minVal ) pos = 0; else pos = bins - 1; } else { // no tail bins and we are outside if ( val < minVal ) pos = Long.MIN_VALUE; else pos = Long.MAX_VALUE; } return pos; }
@Override public long map( final T value ) { final long val = value.getIntegerLong(); long pos; if ( val >= minVal && val <= maxVal ) { pos = val - minVal; if ( tailBins ) pos++; } else if ( tailBins ) { if ( val < minVal ) pos = 0; else pos = bins - 1; } else { // no tail bins and we are outside if ( val < minVal ) pos = Long.MIN_VALUE; else pos = Long.MAX_VALUE; } return pos; }
/** * Throws an AssertionError, if the content or intervals of the two images differ. * Comparision is done pixel wise. Two pixels are considered equal, if the values * returned by {@link IntegerType#getIntegerLong()} are equal. */ public static void assertImageEqualsIntegerType( final RandomAccessibleInterval< ? extends IntegerType< ? > > actual, final RandomAccessibleInterval< ? extends IntegerType< ? > > expected ) { assertImageEquals( actual, expected, ( a, e ) -> a.getIntegerLong() == e.getIntegerLong() ); }
/** * Throws an AssertionError, if the content or intervals of the two images differ. * Comparision is done pixel wise. Two pixels are considered equal, if the values * returned by {@link IntegerType#getIntegerLong()} are equal. */ public static void assertImageEqualsIntegerType( final RandomAccessibleInterval< ? extends IntegerType< ? > > actual, final RandomAccessibleInterval< ? extends IntegerType< ? > > expected ) { assertImageEquals( actual, expected, ( a, e ) -> a.getIntegerLong() == e.getIntegerLong() ); }
@Override public final void convert(final IntegerType<?> input, final IntegerType<?> output) { output.setInteger(input.getIntegerLong()); } };
@Override public void compute(final T input, final Unsigned4BitType output) { output.set(input.getIntegerLong()); }
@Override public void compute(final T input, final ShortType output) { output.set((short) input.getIntegerLong()); }
@Override public void compute(final T input, final LongType output) { output.set(input.getIntegerLong()); }
@Override public void compute(final T input, final Unsigned12BitType output) { output.set(input.getIntegerLong()); }
@Override public void compute(final T input, final ByteType output) { output.set((byte) input.getIntegerLong()); }
@Override public void compute(final T input, final UnsignedIntType output) { output.set(input.getIntegerLong()); }
@Override public void compute(final T input, final BitType output) { output.set(input.getIntegerLong() != 0); }
@Override public void compute(final T input, final Unsigned2BitType output) { output.set(input.getIntegerLong()); }
@Override public void compute(final T input, final UnsignedLongType output) { output.set(input.getIntegerLong()); }
@Override public boolean conforms() { final Object inType = in().firstElement(); // HACK: Help the matcher overcome generics limitations. if (!(inType instanceof IntegerType)) return false; // HACK: Reject types that are small. // Because the InvertII is faster. // TODO: Think of a better solution. final T copy = in().firstElement().createVariable(); copy.setInteger(Long.MAX_VALUE); return copy.getIntegerLong() == Long.MAX_VALUE; }
/** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends IntegerType< T >> void copy( final Img< T > src, final long[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.getIntegerLong(); } }
/** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends IntegerType< T >> void copy( final Img< T > src, final long[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.getIntegerLong(); } }
/** Returns the histogram at each location. The same instance of {@code Img<T>} is returned every time. */ @Override public Histogram<R> get() { // Set all bins to zero histogram.clearBins(); // Setup to compute cell dimensions histogram.initPositions(this, 1); // for (int o=0; o<offsets.length; ++o) { for (int d=0; d<n; ++d) { // position[d] is here // + 1 to move over the leading zeros in integralHistogram // + offset to go to the right corner final long pos = inside(position[d] + 1 + offsets[o].getLongPosition(d), d); histogram.updatePositions(pos, d); ra.setPosition(pos, d); } for (int i=0; i<histogram.bins.length; ++i) { ra.setPosition(i, n); // n coincides with the index of the last dimension of the integral histogram image histogram.bins[i] += signs[o] * ra.get().getIntegerLong(); } } histogram.updatePixelCount(); return histogram; }