scripts/FilterBank.py
def G2_getfeatures(ims, fil_paras, gridshape, mode="reflect", cval=0):
    '''
    A routine which takes an array of images with 4 coords.
    Dim 1 and 2: pixel position.
    Dim 3: RGB channel index.
    Dim 4: Time index.
    '''
    
    num_ims = ims.shape[3]
    num_feats = gridshape[0] * gridshape[1]
    
    out = np.zeros(num_ims*num_feats, dtype=np.float32).reshape((num_ims,num_feats))
    
    # Generate the kernel prior to loop over images.
    fil_values = fil_kernel(paras=fil_paras, n_stds=2)
    
    # Iterate over images.
    for i in range(num_ims):
        
        featvec = np.arange(0, dtype=np.float32)
        
        # Slice -> XYZ -> CIE Lab -> Take only Luminance channel.
        im = col.xyz2lab(col.rgb2xyz(ims[:,:,:,i]))[:,:,0]
        
        # Convolution.
        fil_response_real = ndi.convolve(input=im,
                                         weights=fil_values["real"],
                                         mode=mode, cval=cval)
        fil_response_imag = ndi.convolve(input=im,
                                         weights=fil_values["imag"],
                                         mode=mode, cval=cval)
        fil_response_magnitude = np.sqrt((fil_response_real**2 + fil_response_imag**2))
        
        # Per-patch statistics.
        imstats = patch_stats(image=fil_response_magnitude, grid_h=gridshape[0], grid_w=gridshape[1])
            
        # Pass per-patch statistics through non-linearity to compute final feature vector.
        imfeats = nonlin(imstats["mean"])
        
        # Store the feature vector for this image.
        out[i,:] = imfeats
    
    # Output is the array of feature vectors, one feature vector for each image.
    return out

    A routine which takes an array of images with 4 coords.
    Dim 1 and 2: pixel position.
    Dim 3: RGB channel index.
    Dim 4: Time index.
    
A routine which takes an array of images with 4 coords.
Dim 1 and 2: pixel position.
Dim 3: RGB channel index.
Dim 4: Time index.
A routine which takes an array of images with 4 coords . Dim 1 and 2 : pixel position . Dim 3 : RGB channel index . Dim 4 : Time index .
def G2_getfeatures(ims, fil_paras, gridshape, mode="reflect", cval=0):
    num_ims = ims.shape[3]
    num_feats = gridshape[0] * gridshape[1]
    out = np.zeros(num_ims*num_feats, dtype=np.float32).reshape((num_ims,num_feats))
    fil_values = fil_kernel(paras=fil_paras, n_stds=2)
    for i in range(num_ims):
        featvec = np.arange(0, dtype=np.float32)
        im = col.xyz2lab(col.rgb2xyz(ims[:,:,:,i]))[:,:,0]
        fil_response_real = ndi.convolve(input=im,
                                         weights=fil_values["real"],
                                         mode=mode, cval=cval)
        fil_response_imag = ndi.convolve(input=im,
                                         weights=fil_values["imag"],
                                         mode=mode, cval=cval)
        fil_response_magnitude = np.sqrt((fil_response_real**2 + fil_response_imag**2))
        imstats = patch_stats(image=fil_response_magnitude, grid_h=gridshape[0], grid_w=gridshape[1])
        imfeats = nonlin(imstats["mean"])
        out[i,:] = imfeats
    return out
def G2_getfeatures ( ims , fil_paras , gridshape , mode = "reflect" , cval = 0 ) : num_ims = ims . shape [ 3 ] num_feats = gridshape [ 0 ] * gridshape [ 1 ] out = np . zeros ( num_ims * num_feats , dtype = np . float32 ) . reshape ( ( num_ims , num_feats ) ) fil_values = fil_kernel ( paras = fil_paras , n_stds = 2 ) for i in range ( num_ims ) : featvec = np . arange ( 0 , dtype = np . float32 ) im = col . xyz2lab ( col . rgb2xyz ( ims [ : , : , : , i ] ) ) [ : , : , 0 ] fil_response_real = ndi . convolve ( input = im , weights = fil_values [ "real" ] , mode = mode , cval = cval ) fil_response_imag = ndi . convolve ( input = im , weights = fil_values [ "imag" ] , mode = mode , cval = cval ) fil_response_magnitude = np . sqrt ( ( fil_response_real ** 2 + fil_response_imag ** 2 ) ) imstats = patch_stats ( image = fil_response_magnitude , grid_h = gridshape [ 0 ] , grid_w = gridshape [ 1 ] ) imfeats = nonlin ( imstats [ "mean" ] ) out [ i , : ] = imfeats return out
A routine which takes an array of images with 4 coords.
A routine which takes an array of images with 4 coords .
'''
    A routine which takes an array of images with 4 coords.
    Dim 1 and 2: pixel position.
    Dim 3: RGB channel index.
    Dim 4: Time index.
    ''' # Generate the kernel prior to loop over images. # Iterate over images. # Slice -> XYZ -> CIE Lab -> Take only Luminance channel. # Convolution. # Per-patch statistics. # Pass per-patch statistics through non-linearity to compute final feature vector. # Store the feature vector for this image. # Output is the array of feature vectors, one feature vector for each image.
ims
fil_paras
gridshape
mode
cval