import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; /** Column-jitter (stripe) amplitude inside a flat region of a rendered photo. */ public class StripeCheck { public static void main(String[] a) throws Exception { BufferedImage im = ImageIO.read(new File(a[0])); int x0 = Integer.parseInt(a[1]), y0 = Integer.parseInt(a[2]); int w = Integer.parseInt(a[3]), h = Integer.parseInt(a[4]); double[] col = new double[w]; double lo = 255, hi = 0; for (int y = y0; y < y0 + h; y++) for (int x = x0; x < x0 + w; x++) { int c = im.getRGB(x, y); int l = (((c >> 16) & 0xFF) * 299 + ((c >> 8) & 0xFF) * 587 + (c & 0xFF) * 114) / 1000; col[x - x0] += l; if (l < lo) lo = l; if (l > hi) hi = l; } for (int i = 0; i < w; i++) col[i] /= h; double hf = 0; int n = 0; for (int i = 1; i < w - 1; i++) { hf += Math.abs(col[i] - (col[i-1] + col[i+1]) / 2); n++; } hf /= n; System.out.printf("%-28s region %dx%d luma %.0f..%.0f (range %.0f) colJitter=%.2f = %.1f%% of local range%n", new File(a[0]).getName(), w, h, lo, hi, hi - lo, hf, 100 * hf / Math.max(1, hi - lo)); } }