Class HornSchunckPyramid<T extends ImageGray<T>>

java.lang.Object
boofcv.alg.flow.DenseFlowPyramidBase<T>
boofcv.alg.flow.HornSchunckPyramid<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.
  • Field Details

    • flowX

      protected GrayF32 flowX
    • flowY

      protected GrayF32 flowY
    • initFlowX

      protected GrayF32 initFlowX
    • initFlowY

      protected GrayF32 initFlowY
    • warpImage2

      protected GrayF32 warpImage2
    • warpDeriv2X

      protected GrayF32 warpDeriv2X
    • warpDeriv2Y

      protected GrayF32 warpDeriv2Y
  • Constructor Details

    • HornSchunckPyramid

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

    • 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>>
      Parameters:
      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.
      Overrides:
      interpolateFlowScale in class DenseFlowPyramidBase<T extends ImageGray<T>>
    • warpImageTaylor

      protected void warpImageTaylor(GrayF32 before, GrayF32 flowX, GrayF32 flowY, GrayF32 after)
      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.
      Overrides:
      warpImageTaylor 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()