knn
Class StereoFilterBank

java.lang.Object
  |
  +--knn.StereoFilterBank
Direct Known Subclasses:
DOGFilterBank

public class StereoFilterBank
extends java.lang.Object

This class implements a stereo filterbank, i.e. a sort of super-convolver which with one method call computes multiple stereo difference images. Also computes a depth map, which has the minimal stereo shift for each pixel. The cruve of xshift versus stereo difference turns out tbe usually sinusoid or at least sigmoid in shape. You look for the zerocrossing closest to the 0 xshift. Copyright (c) 1999-2004, Michael Abramoff. All rights reserved.


Field Summary
protected  int n
           
protected  int nrOrders
           
protected  float[] scales
           
protected  float[] xshifts
           
 
Constructor Summary
StereoFilterBank()
           
StereoFilterBank(float[] scales, float[] xshifts)
           
 
Method Summary
static Feature D(float[] image_left, float[] image_right, int width, double scale, float[] xshifts, java.lang.String extraText)
          Calculate a depth map at the chosen scale.
 Feature depth(float[] left_image, float[] right_image, int width, java.lang.String extraText)
          Compute a depth map.
 Feature filter(int filternumber, float[] left_image, float[] right_image, int width, java.lang.String extraText)
          Apply the filter to a stereo pair.
 int getNumber()
           
static float[] linzeros(float[][] mys, float[] yxs, int width, int binning)
          Fit a linear regression line to each of the vectors 0..N*width in matrix[Nxwidth][M] (which is an image of vectors) and return a vector with the zerocrossings of the regression line.
static float[] linzerosOld(float[][] mys, float[] yxs, int width, int binning)
          Fit a linear regression line to each of the vectors 0..N*width in matrix[Nxwidth][M] (which is an image of vectors) and return a vector with the zerocrossings of the regression line.
protected static java.lang.String name(double scale, double xshift, double yshift, java.lang.String extraText)
           
protected  double[] params(int filternumber)
          Determine the order, scale and orientation of a numbered filter.
static Feature S(float[] image_left, float[] image_right, int width, double scale, double xshift, double yshift, java.lang.String extraText)
          Compute a stereo difference image.
 java.lang.String toString(int filternumber, java.lang.String preString)
          Return a descriptive String for this filter number.
static java.lang.String toString(java.lang.String preString)
          Return a descriptive String for a depth map number.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scales

protected float[] scales

xshifts

protected float[] xshifts

nrOrders

protected int nrOrders

n

protected int n
Constructor Detail

StereoFilterBank

public StereoFilterBank()

StereoFilterBank

public StereoFilterBank(float[] scales,
                        float[] xshifts)
Method Detail

getNumber

public int getNumber()

toString

public java.lang.String toString(int filternumber,
                                 java.lang.String preString)
Return a descriptive String for this filter number.

toString

public static java.lang.String toString(java.lang.String preString)
Return a descriptive String for a depth map number.

name

protected static java.lang.String name(double scale,
                                       double xshift,
                                       double yshift,
                                       java.lang.String extraText)

params

protected double[] params(int filternumber)
Determine the order, scale and orientation of a numbered filter.
Returns:
a double[2] with the
 scale
 shifts
 in that order.

filter

public Feature filter(int filternumber,
                      float[] left_image,
                      float[] right_image,
                      int width,
                      java.lang.String extraText)
Apply the filter to a stereo pair. The filter is determined by the currentFilter number which indicates which scale, order and orientation to use.

depth

public Feature depth(float[] left_image,
                     float[] right_image,
                     int width,
                     java.lang.String extraText)
              throws java.lang.Exception
Compute a depth map. The filter is determined by the currentFilter number which indicates which scale, order and orientation to use.

S

public static Feature S(float[] image_left,
                        float[] image_right,
                        int width,
                        double scale,
                        double xshift,
                        double yshift,
                        java.lang.String extraText)
Compute a stereo difference image. This is the subtraction of convoluted right from convoluted left (shifted xhsift, yshift pixels) at order order and scale. This can be optimized (in terms of fewer dimensions) by replacing a set of shifts, with one image with the smallest shift for each pixel.
Parameters:
image_left - the left image
image_right - the right image.
width - the width of these images
xshift - the x shift to perform.
yshift - the x shift to perform.
scale - the scales at which to perform the shift (firtst do the convolution with a Gaussian kernel of order and scale).
featureNames - a Vector containing the list of feature names corresponding to ft.
Returns:
ft, a Feature with the shift image.

D

public static Feature D(float[] image_left,
                        float[] image_right,
                        int width,
                        double scale,
                        float[] xshifts,
                        java.lang.String extraText)
                 throws java.lang.Exception
Calculate a depth map at the chosen scale. Computes the sizes of the difference at many different shifts, does a linear regression on these sizes for each pixel, and computes the zero-crossing for that equation for each pixel.
Parameters:
image_left - the left image
image_right - the right image.
width - the width of these images
xshifts - the x shifts to perform.
scale - the scales at which to perform the shift (firtst do the convolution with a Gaussian kernel of order and scale).
Returns:
ft, a Feature with the depth map.

linzeros

public static float[] linzeros(float[][] mys,
                               float[] yxs,
                               int width,
                               int binning)
Fit a linear regression line to each of the vectors 0..N*width in matrix[Nxwidth][M] (which is an image of vectors) and return a vector with the zerocrossings of the regression line. Uses bijfit package for least squares regression.
Parameters:
mys - a matrix[N*width][M] of y values, which is an image.
width - the width in pixels of m.
binning: - how many pixels to bin over in vertical and horizontal directions of the image.
yxs - a vector with the x values corresponding to the y - values.
Returns:
a vector map[Nxwidth] with the zero crossings of each fit.

linzerosOld

public static float[] linzerosOld(float[][] mys,
                                  float[] yxs,
                                  int width,
                                  int binning)
Fit a linear regression line to each of the vectors 0..N*width in matrix[Nxwidth][M] (which is an image of vectors) and return a vector with the zerocrossings of the regression line.
Parameters:
mys - a matrix[N*width][M] of y values, which is an image.
width - the width in pixels of m.
binning: - how many pixels to bin over in vertical and horizontal directions of the image.
yxs - a vector with the x values corresponding to the y - values.
Returns:
a vector map[Nxwidth] with the zero crossings of each fit.