/** * Draws a filled rectangle that is aligned along the image axis inside the image. * * @param img Image the rectangle is drawn in. Modified * @param value Value of the rectangle * @param x0 Top left x-coordinate * @param y0 Top left y-coordinate * @param width Rectangle width * @param height Rectangle height */ public static void fillRectangle(GrayS64 img, long value, int x0, int y0, int width, int height) { int x1 = x0 + width; int y1 = y0 + height; if( x0 < 0 ) x0 = 0; if( x1 > img.width ) x1 = img.width; if( y0 < 0 ) y0 = 0; if( y1 > img.height ) y1 = img.height; for (int y = y0; y < y1; y++) { for (int x = x0; x < x1; x++) { img.set(x, y, value); } } }
@Override public void set(int x, int y, Number num) { image.set(x,y,num.intValue()); }
public static void convolve( GrayS64 integral , IntegralKernel kernel, GrayS64 output ) { for( int y = 0; y < integral.height; y++ ) { for( int x = 0; x < integral.width; x++ ) { long total = 0; for( int i = 0; i < kernel.blocks.length; i++ ) { ImageRectangle b = kernel.blocks[i]; total += block_zero(integral,x+b.x0,y+b.y0,x+b.x1,y+b.y1)*kernel.scales[i]; } output.set(x,y,total); } } }
public static void set(ImageGray img, int x, int y, double value) { if (GrayI.class.isAssignableFrom(img.getClass())) { ((GrayI)img).set(x,y,(int)value); } else if (img instanceof GrayF32) { ((GrayF32) img).set(x, y,(float)value); } else if (img instanceof GrayF64) { ((GrayF64) img).set(x, y, value); } else if (img instanceof GrayS64) { ((GrayS64) img).set(x, y, (long)value); } else { throw new IllegalArgumentException("Unknown or incompatible image type: " + img.getClass().getSimpleName()); } }
@Override public void setOutside(int x, int y, long val) { image.set(colWrap.getIndex(x) , rowWrap.getIndex(y),val); } }
public void set( int x , int y , long value ) { if( image.isInBounds(x,y) ) image.set(x,y,value); setOutside( x , y , value); }
total += block_zero(integral,x+b.x0,y+b.y0,x+b.x1,y+b.y1)*kernel.scales[i]; output.set(x,y,total); total += block_zero(integral,x+b.x0,y+b.y0,x+b.x1,y+b.y1)*kernel.scales[i]; output.set(x,y,total); total += block_zero(integral,x+b.x0,y+b.y0,x+b.x1,y+b.y1)*kernel.scales[i]; output.set(x,y,total); total += block_zero(integral,x+b.x0,y+b.y0,x+b.x1,y+b.y1)*kernel.scales[i]; output.set(x,y,total);