### Question:
Intensify extends Filter { @Override public void filter(BufferedImage image) { for (int i = 0; i < image.getWidth(); i++) { for (int j = 0; j < image.getHeight(); j++) { int rgb00 = image.getRGB(bound(0, image.getWidth(), i-1), bound(0, image.getHeight(), j-1)); int rgb01 = image.getRGB(bound(0, image.getWidth(), i-1), bound(0, image.getHeight(), j)); int rgb02 = image.getRGB(bound(0, image.getWidth(), i-1), bound(0, image.getHeight(), j+1)); int rgb11 = image.getRGB(i, j); int rgb20 = image.getRGB(bound(0, image.getWidth(), i+1), bound(0, image.getHeight(), j-1)); int rgb21 = image.getRGB(bound(0, image.getWidth(), i+1), bound(0, image.getHeight(), j)); int rgb22 = image.getRGB(bound(0, image.getWidth(), i+1), bound(0, image.getHeight(), j+1)); int m = Mathematics.intensify(ARGB.rawA(rgb11), ARGB.rawR(rgb00), ARGB.rawG(rgb11), ARGB.rawB(rgb22)); int n = Mathematics.intensify(ARGB.rawA(rgb11), ARGB.rawR(rgb01), ARGB.rawG(rgb11), ARGB.rawB(rgb21)); int o = Mathematics.intensify(ARGB.rawA(rgb11), ARGB.rawR(rgb02), ARGB.rawG(rgb11), ARGB.rawB(rgb20)); long avg = (long) m + m + m + n + n + o + o + o; image.setRGB(i, j, ((int)avg>>3) | 0xFF000000); } } }  @Override void filter(BufferedImage image);  }### Answer:
@Test public void testIntensifyRealImage() throws Exception { BufferedImage before = ImageIO.read(ClassLoader.getSystemResource("3kitties.jpg")); BufferedImage after = new BufferedImage(before.getWidth(), before.getHeight(), before.getType()); after.setData(before.getData()); new Intensify().filter(after); int rgb = after.getRGB(0, 0); Assert.assertEquals(ARGB.rawA(rgb), 0xFF); }
@Test public void testIntensifyBlack() throws Exception { BufferedImage before; before = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB); for (int i = 0; i < before.getWidth(); i++) { for (int j = 0; j < before.getHeight(); j++) { before.setRGB(i, j, 0xFF000000); } } BufferedImage after = new BufferedImage(before.getWidth(), before.getHeight(), before.getType()); after.setData(before.getData()); new Intensify().filter(after); int rgb = after.getRGB(0, 0); }
@Test public void testIntensifyBad() throws Exception { BufferedImage before; before = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB); for (int i = 0; i < before.getWidth(); i++) { for (int j = 0; j < before.getHeight(); j++) { before.setRGB(i, j, 0xFF0F0F0F); } } BufferedImage after = new BufferedImage(before.getWidth(), before.getHeight(), before.getType()); after.setData(before.getData()); new Intensify().filter(after); int rgb = after.getRGB(0, 0); Assert.assertEquals(ARGB.rawA(rgb), 0xFF); }