@Override public int unsafe_get(int x, int y) { return data[getIndex(x, y)] & 0xFF; }
@Override public float compute(int x, int y) { int index = imageRed.getIndex(x,y); int r = imageRed.data[index] & 0xFF; int g = imageGreen.data[index] & 0xFF; int b = imageBlue.data[index] & 0xFF; ColorHsv.rgbToHsv(r,g,b,hsv); if( hsv[2] < minimumValue ) return 0f; return binsH[ (int)(hsv[0] / sizeH) ]*binsS[ (int)(hsv[1] / sizeS) ]; } }
@Override public float compute(int x, int y) { int index = imageRed.getIndex(x,y); int r = imageRed.data[index] & 0xFF; int g = imageGreen.data[index] & 0xFF; int b = imageBlue.data[index] & 0xFF; ColorHsv.rgbToHsv(r,g,b,hsv); if( hsv[2] < minimumValue ) return 0f; int binH = (int)(hsv[0] / sizeH); int binS = (int)(hsv[1] / sizeS); return bins[ binH*numHistogramBins + binS ]; } }
for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); System.arraycopy(from.data,indexFrom,to.data,indexTo,from.width); for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); int indexEndTo = indexTo + from.width; for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y); int indexEndTo = indexTo + from.width; for (int y = 0; y < from.height; y++) { int indexFrom = from.getIndex(0, y); int indexTo = to.getIndex(0, y);
public static void convert( GrayU8 from, GrayI8 to ) { if (from.isSubimage() || to.isSubimage()) { 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 < from.width; x++) { to.data[indexTo++] = ( byte )( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height; System.arraycopy(from.data, 0, to.data, 0, N); } }
public static void convert( GrayU8 from, GrayF32 to ) { if (from.isSubimage() || to.isSubimage()) { 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 < from.width; x++) { to.data[indexTo++] = ( float )( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height; for (int i = 0; i < N; i++) { to.data[i] = ( float )( from.data[i] & 0xFF); } } }
public static void convert( GrayU8 from, GrayS32 to ) { if (from.isSubimage() || to.isSubimage()) { 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 < from.width; x++) { to.data[indexTo++] = ( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height; for (int i = 0; i < N; i++) { to.data[i] = ( from.data[i] & 0xFF); } } }
public static void convert( GrayU8 from, GrayI16 to ) { if (from.isSubimage() || to.isSubimage()) { 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 < from.width; x++) { to.data[indexTo++] = ( short )( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height; for (int i = 0; i < N; i++) { to.data[i] = ( short )( from.data[i] & 0xFF); } } }
public static void convert( GrayU8 from, GrayS64 to ) { if (from.isSubimage() || to.isSubimage()) { 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 < from.width; x++) { to.data[indexTo++] = ( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height; for (int i = 0; i < N; i++) { to.data[i] = ( from.data[i] & 0xFF); } } }
public static void convert( GrayU8 from, GrayF64 to ) { if (from.isSubimage() || to.isSubimage()) { 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 < from.width; x++) { to.data[indexTo++] = ( double )( from.data[indexFrom++] & 0xFF); } } } else { final int N = from.width * from.height; for (int i = 0; i < N; i++) { to.data[i] = ( double )( from.data[i] & 0xFF); } } }
/** * Scales an image up using interpolation */ public static void scaleImageUp(GrayU8 input , GrayU8 output , int scale , InterpolatePixelS<GrayU8> interp ) { output.reshape(input.width*scale,input.height*scale); float fdiv = 1/(float)scale; interp.setImage(input); for (int y = 0; y < output.height; y++) { float inputY = y*fdiv; int indexOutput = output.getIndex(0,y); for (int x = 0; x < output.width; x++) { float inputX = x*fdiv; output.data[indexOutput++] = (byte)interp.get(inputX,inputY); } } }
indexBinary = binary.getIndex(x,y); indexLabel = labeled.getIndex(x-1,y-1); add(x,y);
int indexOut = output.getIndex(x,y); open.grow().set(x,y); output.data[indexOut] = 1;