def build_sp_levels(self, im, height, use_band_fb=True): """ Recursively build the levels of a steerable pyramid """ if height <= 0: return [[im]] bands = [] if use_band_fb: bands_tmp = correlate_and_downsample(im, self.filter_set.band_fb) #imshow(bands_tmp, 'bands_tmp') for i in range(0, bands_tmp.shape[2]): bands.append(bands_tmp[:,:,i]) else: for filt in self.filter_set.band_filts: band = correlate_and_downsample(im, filt) bands.append(band) lo = correlate_and_downsample(im, self.filter_set.lo_filt, 2) print lo.shape pyramid_below = self.build_sp_levels(lo, height-1) return [bands] + pyramid_below
def process_image(self, im, pyramid_height=None, upsample=True): if pyramid_height is None: fs = self.filter_set.lo_filt.shape[0] pyramid_height = max_pyramid_height(im.shape, fs) print 'pyramid height:', pyramid_height hi0 = correlate_and_downsample(im, self.filter_set.hi0_filt) lo0 = correlate_and_downsample(im, self.filter_set.lo0_filt) #imshow(hi0, 'hi0') #imshow(lo0, 'lo0') self.residual_hipass = hi0 pyramid = self.build_sp_levels(lo0, pyramid_height) if upsample: return self.upsample_pyramid(pyramid) else: return pyramid