@Override public void unsafe_set(int x, int y, int... value) { int index = getIndex(x, y, 0); for (int i = 0; i < numBands; i++, index++) { data[index] = (short)value[i]; } }
/** * Rotates the image 90 degrees in the clockwise direction. */ public static void rotateCW( InterleavedI16 input , InterleavedI16 output ) { if( input.width != output.height || input.height != output.width || input.numBands != output.numBands ) throw new IllegalArgumentException("Incompatible shapes"); int h = input.height-1; for( int y = 0; y < input.height; y++ ) { int indexSrc = input.startIndex + y*input.stride; for (int x = 0; x < input.width; x++) { int indexDst = output.getIndex(h-y,x); int end = indexSrc + input.numBands; while( indexSrc != end ) { output.data[indexDst++] = input.data[indexSrc++]; } } } }
/** * Rotates the image 90 degrees in the counter-clockwise direction. */ public static void rotateCCW( InterleavedI16 input , InterleavedI16 output ) { if( input.width != output.height || input.height != output.width || input.numBands != output.numBands ) throw new IllegalArgumentException("Incompatible shapes"); int w = input.width-1; for( int y = 0; y < input.height; y++ ) { int indexSrc = input.startIndex + y*input.stride; for (int x = 0; x < input.width; x++) { int indexDst = output.getIndex(y,w-x); int end = indexSrc + input.numBands; while( indexSrc != end ) { output.data[indexDst++] = input.data[indexSrc++]; } } } }
/** * Sets the pixel's value for all the bands using an array. * * @param x pixel coordinate. * @param y pixel coordinate. * @param value The pixel's new value for each band. */ public void set(int x, int y, short... value) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds"); int index = getIndex(x, y, 0); for (int i = 0; i < numBands; i++, index++) { data[index] = value[i]; } }
/** * Returns the pixel's value for all the bands as an array. * * @param x pixel coordinate. * @param y pixel coordinate. * @param storage If not null then the pixel's value is written here. If null a new array is created. * @return The pixel's value. */ public short[] get(int x, int y, short[] storage) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds"); if (storage == null) { storage = new short[numBands]; } int index = getIndex(x, y, 0); for (int i = 0; i < numBands; i++, index++) { storage[i] = data[index]; } return storage; }
@Override public void setBand(int x, int y, int band, int value) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds."); if (band < 0 || band >= numBands) throw new ImageAccessException("Invalid band requested."); data[getIndex(x, y, band)] = (short)value; }
/** * Returns the value of the specified band in the specified pixel. * * @param x pixel coordinate. * @param y pixel coordinate. * @param band which color band in the pixel * @param value The new value of the element. */ public void setBand(int x, int y, int band, short value) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds."); if (band < 0 || band >= numBands) throw new ImageAccessException("Invalid band requested."); data[getIndex(x, y, band)] = value; }
public static void convert( InterleavedU16 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] & 0xFFFF); } } } else { final int N = from.width * from.height * from.getNumBands(); System.arraycopy(from.data, 0, to.data, 0, N); } }
public static void convert( InterleavedS16 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( from.data[indexFrom++] ); } } } else { final int N = from.width * from.height * from.getNumBands(); System.arraycopy(from.data, 0, to.data, 0, N); } }
public static void convert( InterleavedS8 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] ); } } } else { final int N = from.width * from.height * from.getNumBands(); for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] ); } } }
public static void convert( InterleavedS64 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] ); } } } else { final int N = from.width * from.height * from.getNumBands(); for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] ); } } }
public static void convert( InterleavedF32 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] ); } } } else { final int N = from.width * from.height * from.getNumBands(); for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] ); } } }
public static void convert( InterleavedU8 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height * from.getNumBands(); for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] & 0xFF); } } }
public static void convert( InterleavedF64 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] ); } } } else { final int N = from.width * from.height * from.getNumBands(); for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] ); } } }
public static void convert( InterleavedS32 from, InterleavedI16 to ) { if (from.isSubimage() || to.isSubimage()) { final int N = from.width * from.getNumBands(); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); for (int x = 0; x < N; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] ); } } } else { final int N = from.width * from.height * from.getNumBands(); for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] ); } } }