Class PerceptualImageDifferencing

    • Field Detail

      • KERNEL

        private static final float[] KERNEL
        Filter kernel for Laplacian convolution.
      • colorFactor

        private final double colorFactor
      • fieldOfView

        private final double fieldOfView
      • gamma

        private final double gamma
      • luminance

        private final double luminance
      • luminanceOnly

        private final boolean luminanceOnly
      • thresholdPixels

        private final int thresholdPixels
      • failFast

        private final boolean failFast
      • numOneDegreePixels

        private final double numOneDegreePixels
      • adaptationLevel

        private final int adaptationLevel
      • lut

        private final double[] lut
    • Constructor Detail

      • PerceptualImageDifferencing

        public PerceptualImageDifferencing​(double fieldOfView,
                                           int thresholdPixels,
                                           boolean failFast,
                                           double gamma,
                                           double luminance,
                                           boolean luminanceOnly,
                                           double colorFactor)
        Creates PerceptualDiff instance with specified parameters.
        Parameters:
        fieldOfView - field of view in degrees
        thresholdPixels - failure threshold
        failFast - whether to fail immediately when threshold is reached
        gamma - value to convert rgb into linear space
        luminance - white luminance
        luminanceOnly - whether to ignore chroma in comparison
        colorFactor - how much of color to use
    • Method Detail

      • construct

        protected static void construct​(float[][] levels,
                                        int width,
                                        int height)
        Constructs the Laplacian pyramid by successively copying earlier levels and blurring them.
      • convolveAndTranspose

        private static void convolveAndTranspose​(float[] src,
                                                 float[] dst,
                                                 int width,
                                                 int height)
        Convolves image src with 1D filter kernel and stores it transposed in dst.

        Adapted from Jerry Huxtable's Gaussian Filter

      • tvi

        private static double tvi​(double adaptationLuminance)
        Given the adaptation luminance, computes the threshold of visibility in cd per m^2.

        TVI means Threshold vs Intensity function.

        This version comes from Ward Larson Siggraph 1997

      • csf

        private static double csf​(double cpd,
                                  double lum)
        Computes the contrast sensitivity function (Barten SPIE 1989) given the cycles per degree (cpd) and luminance (lum).
      • mask

        private static double mask​(double contrast)
        Visual Masking Function from Daly 1993
      • pow

        private static double pow​(double a,
                                  double b)
      • fastpow

        private static double fastpow​(double a,
                                      double b)
        Returns the first argument raised to the power of the second argument.

        This approximate implementation from martin.ankerl.com is several times faster than Math.pow.

        For an implementation with adjustable accuracy, see article by Harrison Ainsworth: Fast pow() With Adjustable Accuracy.

        Parameters:
        a - the base
        b - the exponent
        Returns:
        the value ab
      • dump

        public void dump()
        Prints some parameters to the log.
      • compare

        public void compare​(ForkJoinPool pool,
                            BufferedImage imgA,
                            BufferedImage imgB,
                            BufferedImage imgDiff)
        Compares images using Yee's method.

        References: A Perceptual Metric for Production Testing, Hector Yee, Journal of Graphics Tools 2004.

        Parameters:
        pool - fork-join pool for task execution
        imgA - first of two images to compare
        imgB - second of two images to compare
        imgDiff - accumulates differences (optional)
      • convert

        protected void convert​(int[] rgb,
                               float[] a,
                               float[] b,
                               float[] lum)
        Converts RGB to AB and luminance.
        Parameters:
        rgb - pixel values
        a - A
        b - B
        lum - Y * luminance