Class HornSchunckPyramid<T extends ImageGray<T>>

  • public class HornSchunckPyramid<T extends ImageGray<T>>
    extends DenseFlowPyramidBase<T>

    Pyramidal implementation of Horn-Schunck [2] based on the discussion in [1]. The problem formulation has been modified from the original found in [2] to account for larger displacements. The Euler-Lagrange equations are solved using Successive Over-Relaxation (SOR).

    1. Meinhardt-Llopis, Enric and Sánchez Pérez, Javier and Kondermann, Daniel, "Horn-Schunck Optical Flow with a Multi-Scale Strategy" vol 3, 2013, Image Processing On Line
    2. Horn, Berthold K., and Brian G. Schunck. "Determining optical flow." 1981 Technical Symposium East. International Society for Optics and Photonics, 1981.
    • Constructor Detail

      • HornSchunckPyramid

        public HornSchunckPyramid​(ConfigHornSchunckPyramid config,
                                  InterpolatePixelS<GrayF32> interp)
        Configures flow estimation
        config - Configuration parameters
        interp - Interpolation for image flow between image layers and warping. Overrides selection in config.
    • Method Detail

      • process

        public void process​(ImagePyramid<GrayF32> image1,
                            ImagePyramid<GrayF32> image2)
        Computes dense optical flow from the provided image pyramid. Image gradient for each layer should be computed directly from the layer images.
        Specified by:
        process in class DenseFlowPyramidBase<T extends ImageGray<T>>
        image1 - Pyramid of first image
        image2 - Pyramid of second image
      • interpolateFlowScale

        protected void interpolateFlowScale​(int widthNew,
                                            int heightNew)
        Provides an initial estimate for the flow by interpolating values from the previous layer.
      • interpolateFlowScale

        protected void interpolateFlowScale​(GrayF32 prev,
                                            GrayF32 curr)
        Takes the flow from the previous lower resolution layer and uses it to initialize the flow in the current layer. Adjusts for change in image scale.
        interpolateFlowScale in class DenseFlowPyramidBase<T extends ImageGray<T>>
      • processLayer

        protected void processLayer​(GrayF32 image1,
                                    GrayF32 image2,
                                    GrayF32 derivX2,
                                    GrayF32 derivY2)
        Computes the flow for a layer using Taylor series expansion and Successive Over-Relaxation linear solver. Flow estimates from previous layers are feed into this by setting initFlow and flow to their values.
      • A_safe

        protected static float A_safe​(int x,
                                      int y,
                                      GrayF32 flow)
        See equation 25. Safe version
      • A

        protected static float A​(int x,
                                 int y,
                                 GrayF32 flow)
        See equation 25. Fast unsafe version
      • safe

        protected static float safe​(int x,
                                    int y,
                                    GrayF32 image)
        Ensures pixel values are inside the image. If output it is assigned to the nearest pixel inside the image
      • getFlowX

        public GrayF32 getFlowX()
      • getFlowY

        public GrayF32 getFlowY()