private static void checkNeighbour(WritableRaster raster, int x, int y, int thresholdGray, int thresholdCount, int[] count) { if (count[0] > thresholdCount) return; int[] pixel = new int[1]; if (x >= raster.getWidth()) return; if (y >= raster.getHeight()) return; raster.getPixel(x, y, pixel); if (pixel[0] < thresholdGray) { count[0] += 1; if (count[0] < thresholdCount) { // checkNeighbour(raster, x, y, thresholdGray, thresholdCount, count); checkNeighbour(raster, x, y + 1, thresholdGray, thresholdCount, count); checkNeighbour(raster, x + 1, y, thresholdGray, thresholdCount, count); checkNeighbour(raster, x + 1, y + 1, thresholdGray, thresholdCount, count); checkNeighbour(raster, x - 1, y + 1, thresholdGray, thresholdCount, count); } } }
private static void checkNeighbour(WritableRaster raster, int x, int y, int thresholdGray, int thresholdCount, int[] count) { if (count[0] > thresholdCount) return; int[] pixel = new int[1]; if (x >= raster.getWidth()) return; if (y >= raster.getHeight()) return; raster.getPixel(x, y, pixel); if (pixel[0] < thresholdGray) { count[0] += 1; if (count[0] < thresholdCount) { // checkNeighbour(raster, x, y, thresholdGray, thresholdCount, count); checkNeighbour(raster, x, y + 1, thresholdGray, thresholdCount, count); checkNeighbour(raster, x + 1, y, thresholdGray, thresholdCount, count); checkNeighbour(raster, x + 1, y + 1, thresholdGray, thresholdCount, count); checkNeighbour(raster, x - 1, y + 1, thresholdGray, thresholdCount, count); } } }
if (p[0] < thresholdGray) { // thresholding checkNeighbour(raster, x, y, thresholdGray, thresholdCount, count); if (count[0] < thresholdCount) { p[0] = 255;
if (p[0] < thresholdGray) { // thresholding checkNeighbour(raster, x, y, thresholdGray, thresholdCount, count); if (count[0] < thresholdCount) { p[0] = 255;