@Override public void set(int x, int y, Number num) { image.set(x,y,num.intValue()); }
/** * Sets each pixel in the list of clusters to one in the binary image. * * @param clusters List of all the clusters. * @param binary Output */ public static void clusterToBinary( List<List<Point2D_I32>> clusters , GrayU8 binary ) { ImageMiscOps.fill(binary, 0); for( List<Point2D_I32> l : clusters ) { for( Point2D_I32 p : l ) { binary.set(p.x,p.y,1); } } }
public static void edge4(GrayU8 input, GrayU8 output) { for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { if (getT(input, x - 1, y) && getT(input, x + 1, y) && getT(input, x, y - 1) && getT(input, x, y + 1)) output.set(x, y, 0); else output.set(x, y, input.get(x, y)); } } }
public static void erode4(GrayU8 input, GrayU8 output) { for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { if (input.get(x, y) != 0 && getT(input, x - 1, y) && getT(input, x + 1, y) && getT(input, x, y - 1) && getT(input, x, y + 1)) output.set(x, y, 1); else output.set(x, y, 0); } } }
public static void dilate4(GrayU8 input, GrayU8 output) { for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { if (input.get(x, y) != 0 || getF(input, x - 1, y) || getF(input, x + 1, y) || getF(input, x, y - 1) || getF(input, x, y + 1)) output.set(x, y, 1); else output.set(x, y, 0); } } }
for (int i = -r; i <= r; i++) { for (int j = -r; j <= r; j++) { disparity.set(deltaX+x + j, deltaY+y + i, 255);
public static void erode4(GrayU8 input, GrayU8 output) { ImageBorder_S32 in = ImageBorderValue.wrap(input,0); final int h = input.height - 1; final int w = input.width - 1; for (int x = 0; x < input.width; x++) { // check top edge if ((in.get( x, 0) + in.get( x - 1, 0) + in.get( x + 1, 0) + in.get( x, 1)) == 4) output.set(x, 0, 1); else output.set(x, 0, 0); // check bottom edge if ((in.get( x, h) + in.get( x - 1, h) + in.get( x + 1, h) + in.get( x, h - 1)) == 4) output.set(x, h, 1); else output.set(x, h, 0); } for (int y = 0; y < input.height; y++) { // check left edge if ((in.get( 0, y) + in.get( 1, y) + in.get( 0, y - 1) + in.get( 0, y + 1)) == 4) output.set(0, y, 1); else output.set(0, y, 0); // check right edge if ((in.get( w, y) + in.get( w - 1, y) + in.get( w, y - 1) + in.get( w, y + 1)) == 4) output.set(w, y, 1); else output.set(w, y, 0); } }
public static void dilate4(GrayU8 input, GrayU8 output) { ImageBorder_S32 in = ImageBorderValue.wrap(input,0); final int h = input.height - 1; final int w = input.width - 1; for (int x = 0; x < input.width; x++) { // check top edge if ((in.get( x, 0) + in.get( x - 1, 0) + in.get( x + 1, 0) + in.get( x, 1)) > 0) output.set(x, 0, 1); else output.set(x, 0, 0); // check bottom edge if ((in.get( x, h) + in.get( x - 1, h) + in.get( x + 1, h) + in.get( x, h - 1)) > 0) output.set(x, h, 1); else output.set(x, h, 0); } for (int y = 0; y < input.height; y++) { // check left edge if ((in.get( 0, y) + in.get( 1, y) + in.get( 0, y - 1) + in.get( 0, y + 1)) > 0) output.set(0, y, 1); else output.set(0, y, 0); // check right edge if ((in.get( w, y) + in.get( w - 1, y) + in.get( w, y - 1) + in.get( w, y + 1)) > 0) output.set(w, y, 1); else output.set(w, y, 0); } }
output.set(radius,y, (sum*maxValue)/area );
/** * Binary operation which is designed to remove small bits of spurious noise. An 8-neighborhood is used. * If a pixel is connected to less than 2 neighbors then its value zero. If connected to more than 6 then * its value is one. Otherwise it retains its original value. * * @param input Input image. Not modified. * @param output If not null, the output image. If null a new image is declared and returned. Modified. * @return Output image. */ public static void removePointNoise(GrayU8 input, GrayU8 output) { for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { int num = 0; if (getF(input, x - 1, y + 1)) num++; if (getF(input, x, y + 1)) num++; if (getF(input, x + 1, y + 1)) num++; if (getF(input, x + 1, y)) num++; if (getF(input, x + 1, y - 1)) num++; if (getF(input, x, y - 1)) num++; if (getF(input, x - 1, y - 1)) num++; if (getF(input, x - 1, y)) num++; if (num < 2) output.set(x, y, 0); else if (num > 6) output.set(x, y, 1); else output.set(x, y, input.get(x, y)); } } }
public static void edge8(GrayU8 input, GrayU8 output) { for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { if (getT(input, x - 1, y) && getT(input, x + 1, y) && getT(input, x, y - 1) && getT(input, x, y + 1) && getT(input, x - 1, y + 1) && getT(input, x + 1, y + 1) && getT(input, x - 1, y - 1) && getT(input, x + 1, y - 1)) output.set(x, y, 0); else output.set(x, y, input.get(x, y)); } } }
public static void dilate8(GrayU8 input, GrayU8 output) { for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { if (input.get(x, y) != 0 || getF(input, x - 1, y) || getF(input, x + 1, y) || getF(input, x, y - 1) || getF(input, x, y + 1) || getF(input, x - 1, y + 1) || getF(input, x + 1, y + 1) || getF(input, x - 1, y - 1) || getF(input, x + 1, y - 1)) output.set(x, y, 1); else output.set(x, y, 0); } } }
in.get( x - 1, 1) + in.get( x, 1) + in.get( x + 1, 1); if (total < 2) output.set(x, 0, 0); else output.set(x, 0, input.get(x, 0)); in.get( x - 1, h - 1) + in.get( x, h - 1) + in.get( x + 1, h - 1); if (total < 2) output.set(x, h, 0); else output.set(x, h, input.get(x, h)); in.get( 1, y - 1) + in.get( 0, y + 1) + in.get( 1, y + 1); if (total < 2) output.set(0, y, 0); else output.set(0, y, input.get(0, y)); in.get( w, y - 1) + in.get( w - 1, y + 1) + in.get( w, y + 1); if (total < 2) output.set(w, y, 0); else output.set(w, y, input.get(w, y));
public static void erode8(GrayU8 input, GrayU8 output) { output = InputSanityCheck.checkDeclare(input, output); for (int y = 0; y < input.height; y++) { for (int x = 0; x < input.width; x++) { if (input.get(x, y) != 0 && getT(input, x - 1, y) && getT(input, x + 1, y) && getT(input, x, y - 1) && getT(input, x, y + 1) && getT(input, x - 1, y + 1) && getT(input, x + 1, y + 1) && getT(input, x - 1, y - 1) && getT(input, x + 1, y - 1)) output.set(x, y, 1); else output.set(x, y, 0); } } }