Package pyvision :: Package features :: Module v1like
[hide private]
[frames] | no frames]

Module v1like

source code

This module contains code from Nicolas Pinto. Added to PyVision by David Bolme

Pinto N, Cox DD, DiCarlo JJ (2008) Why is Real-World Visual Object Recognition Hard? PLoS Computational Biology 4(1): e27 doi:10.1371/journal.pcbi.0040027

Created on May 29, 2011


Author: bolme

Classes [hide private]
  V1Processing
  MinMaxError
Functions [hide private]
 
gray_convert(arr) source code
 
opp_convert(arr) source code
 
oppnorm_convert(arr, threshold=0.1) source code
 
chrom_convert(arr) source code
 
rg2_convert(arr) source code
 
hsv_convert(arr)
fast rgb_to_hsv using numpy array
source code
 
rgb_convert(arr) source code
 
fastnorm(x)
Fast Euclidean Norm (L2)
source code
 
gabor2d(gw, gh, gx0, gy0, wfreq, worient, wphase, shape)
Generate a gabor 2d array
source code
 
sresample(src, outshape)
Simple 3d array resampling
source code
 
v1like_pool(hin, conv_mode, lsum_ksize, outshape=None, order=1)
V1LIKE Pooling Boxcar Low-pass filter featuremap-wise
source code
 
v1like_filter(hin, conv_mode, filterbank, use_cache=False)
V1LIKE linear filtering Perform separable convolutions on an image with a set of filters
source code
 
get_gabor_filters(params)
Return a Gabor filterbank (generate it if needed)
source code
 
v1like_norm(hin, conv_mode, kshape, threshold)
V1LIKE local normalization
source code
 
v1like_fromarray(arr, params)
Applies a simple V1-like model and generates a feature vector from its outputs.
source code
Variables [hide private]
  V1LIKE_PARAMS_A = {'activ': {'maxout': 1, 'minout': 0}, 'filte...
  V1LIKE_FEATURES_A = {'activ_hists': None, 'filter_hists': None...
  fft_cache = {}
  filt_l = None
  __package__ = 'pyvision.features'
  n = 18
  o = 15
Function Details [hide private]

fastnorm(x)

source code 
Fast Euclidean Norm (L2)

This version should be faster than numpy.linalg.norm if 
the dot function uses blas.

Inputs:
  x -- numpy array

Output:
  L2 norm from 1d representation of x

gabor2d(gw, gh, gx0, gy0, wfreq, worient, wphase, shape)

source code 
Generate a gabor 2d array

Inputs:
  gw -- width of the gaussian envelope
  gh -- height of the gaussian envelope
  gx0 -- x indice of center of the gaussian envelope
  gy0 -- y indice of center of the gaussian envelope
  wfreq -- frequency of the 2d wave
  worient -- orientation of the 2d wave
  wphase -- phase of the 2d wave
  shape -- shape tuple (height, width)

Outputs:
  gabor -- 2d gabor with zero-mean and unit-variance

sresample(src, outshape)

source code 
Simple 3d array resampling

Inputs:
  src -- a ndimensional array (dim>2)
  outshape -- fixed output shape for the first 2 dimensions

Outputs:
   hout -- resulting n-dimensional array

v1like_pool(hin, conv_mode, lsum_ksize, outshape=None, order=1)

source code 
V1LIKE Pooling
Boxcar Low-pass filter featuremap-wise

Inputs:
  hin -- a 3-dimensional array (width X height X n_channels)
  lsum_ksize -- kernel size of the local sum ex: 17
  outshape -- fixed output shape (2d slices)
  order -- XXX

Outputs:
   hout -- resulting 3-dimensional array

v1like_filter(hin, conv_mode, filterbank, use_cache=False)

source code 
V1LIKE linear filtering
Perform separable convolutions on an image with a set of filters

Inputs:
  hin -- input image (a 2-dimensional array)
  filterbank -- TODO list of tuples with 1d filters (row, col)
                used to perform separable convolution
  use_cache -- Boolean, use internal fft_cache (works _well_ if the input
  shapes don't vary much, otherwise you'll blow away the memory)

Outputs:
  hout -- a 3-dimensional array with outputs of the filters
          (width X height X n_filters)

get_gabor_filters(params)

source code 

Return a Gabor filterbank (generate it if needed)

Inputs: params -- filters parameters (dict)

Outputs: filt_l -- filterbank (list)

v1like_norm(hin, conv_mode, kshape, threshold)

source code 
V1LIKE local normalization

Each pixel in the input image is divisively normalized by the L2 norm
of the pixels in a local neighborhood around it, and the result of this
division is placed in the output image.

Inputs:
  hin -- a 3-dimensional array (width X height X rgb)
  kshape -- kernel shape (tuple) ex: (3,3) for a 3x3 normalization
            neighborhood
  threshold -- magnitude threshold, if the vector's length is below
               it doesn't get resized ex: 1.

Outputs:
  hout -- a normalized 3-dimensional array (width X height X rgb)

v1like_fromarray(arr, params)

source code 
Applies a simple V1-like model and generates a feature vector from
its outputs.

Inputs:
  arr -- image's array
  params -- representation parameters (dict)
  featsel -- features to include to the vector (dict)

Outputs:
  fvector -- corresponding feature vector


Variables Details [hide private]

V1LIKE_PARAMS_A

Value:
{'activ': {'maxout': 1, 'minout': 0},
 'filter': {'freqs': [0.5,
                      0.333333333333,
                      0.25,
                      0.166666666667,
                      0.0909090909091,
                      0.0555555555556],
            'kshape': (43, 43),
...

V1LIKE_FEATURES_A

Value:
{'activ_hists': None,
 'filter_hists': None,
 'input_colorhists': None,
 'input_gray': None,
 'normin_hists': None,
 'normout_hists': None,
 'output': True,
 'pool_hists': None}