static BWImage gazelle22_borderImage(IBWIntegralImage unposterized, BWImage posterized) { assertSameSize(unposterized, posterized); int w = posterized.getWidth(), h = posterized.getHeight(); BWImage out = new(w*2+1, h*2+1); for y to h: for x to w: { if (x < w-1) { // check border with right neighbor int posterizedContrast = absDiff(posterized.getInt(x, y), posterized.getInt(x+1, y)); if (posterizedContrast != 0) { int realContrast = absDiff(unposterized.getPixelBrightness(x, y), unposterized.getPixelBrightness(x+1, y)); double ratio = doubleRatio(realContrast, posterizedContrast); out.setPixel(x*2+1, y*2, (float) ratio); out.setPixel(x*2+1, y*2+1, (float) ratio); } } if (y < h-1) { // check border with bottom neighbor int posterizedContrast = absDiff(posterized.getInt(x, y), posterized.getInt(x, y+1)); if (posterizedContrast != 0) { int realContrast = absDiff(unposterized.getPixelBrightness(x, y), unposterized.getPixelBrightness(x, y+1)); double ratio = doubleRatio(realContrast, posterizedContrast); out.setPixel(x*2, y*2+1, (float) ratio); out.setPixel(x*2+1, y*2+1, (float) ratio); } } } ret out; }