diff --git a/.DS_Store b/.DS_Store index b811fe9..1f088fa 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/datasets/dataset_hf5.py b/datasets/dataset_hf5.py index 001ef72..3f7683e 100755 --- a/datasets/dataset_hf5.py +++ b/datasets/dataset_hf5.py @@ -1,6 +1,5 @@ import torch.utils.data as data import torch -from PIL import Image from skimage.io import imread, imsave import numpy as np import random @@ -9,10 +8,7 @@ import h5py import sys import os -sys.path.append('..') from os.path import join -from skimage.transform import rotate -from skimage import img_as_float #=================== Utils ===================# def is_image_file(filename): @@ -24,26 +20,21 @@ def is_image_file(filename): class DataValSet(data.Dataset): def __init__(self, root_dir): - # input_dir = join(root_val_dir, 'LR_Blur') #---------------Input path - #one input & two ground truths + #one input & ground truth self.input_dir = join(root_dir, 'LR_Blur') - self.lr_deblur_dir = join(root_dir, 'LR') self.sr_dir = join(root_dir, 'HR') #Online Loading self.input_names = [x for x in sorted(os.listdir(self.input_dir)) if is_image_file(x)] - self.lr_deblur_names = [x for x in sorted(os.listdir(self.lr_deblur_dir)) if is_image_file(x)] self.hr_names = [x for x in sorted(os.listdir(self.sr_dir)) if is_image_file(x)] def __len__(self): return len(self.hr_names) def __getitem__(self, index): - input = np.asarray(imread(join(self.input_dir, self.input_names[index])).transpose((2, 0, 1)), np.float32).copy() / 255 - target_lr = np.asarray(imread(join(self.lr_deblur_dir, self.lr_deblur_names[index])).transpose((2, 0, 1)), np.float32).copy() /255 - target = np.asarray(imread(join(self.sr_dir, self.hr_names[index])).transpose((2, 0, 1)), np.float32).copy() / 255 - - return input, target_lr, target, self.hr_names[index] + input = np.asarray(imread(join(self.input_dir, self.input_names[index])).transpose((2, 0, 1)), np.float32).copy() / 255 + target = np.asarray(imread(join(self.sr_dir, self.hr_names[index])).transpose((2, 0, 1)), np.float32).copy() / 255 + return input, target #=================== Training ===================# @@ -52,37 +43,35 @@ def __init__(self, h5py_file_path): super(DataSet, self).__init__() self.hdf5_file = h5py_file_path - self.file = h5py.File(self.hdf5_file, 'r') - self.file.keys() - self.inputs = np.array(self.file.get("data")) - self.deblurs = np.array(self.file.get("label_db")) - self.hrs = np.array(self.file.get("label")) + self.file = h5py.File(self.hdf5_file, 'r') + #self.file.keys() + self.inputs = self.file.get("data") + self.deblurs = self.file.get("label_db") + self.hrs = self.file.get("label") def __len__(self): return self.inputs.shape[0] def __getitem__(self, index): - input_patch = self.inputs[index, :, :, :] - deblur_patch = self.deblurs[index, :, :, :] - hr_patch = self.hrs[index, :, :, :] + #print(index) + # numpy + input_patch = np.asarray(self.inputs[index, :, :, :], np.float32) + deblur_patch = np.asarray(self.deblurs[index, :, :, :], np.float32) + hr_patch = np.asarray(self.hrs[index, :, :, :], np.float32) # randomly flip if random.randint(0, 1) == 0: - input_patch = np.flip(input_patch, 1) - deblur_patch = np.flip(deblur_patch, 1) - hr_patch = np.flip(hr_patch, 1) - else: input_patch = np.flip(input_patch, 2) deblur_patch = np.flip(deblur_patch, 2) hr_patch = np.flip(hr_patch, 2) # randomly rotation rotation_times = random.randint(0, 3) - input_patch = np.rot90(input_patch, rotation_times, (1, 2)) - deblur_patch = np.rot90(deblur_patch, rotation_times, (1, 2)) - hr_patch = np.rot90(hr_patch, rotation_times, (1, 2)) + input_patch = np.rot90(input_patch, rotation_times, (1, 2)) + deblur_patch = np.rot90(deblur_patch, rotation_times, (1, 2)) + hr_patch = np.rot90(hr_patch, rotation_times, (1, 2)) - return torch.from_numpy(np.asarray(input_patch, np.float32).copy()),\ - torch.from_numpy(np.asarray(deblur_patch, np.float32).copy()),\ - torch.from_numpy(np.asarray(hr_patch, np.float32).copy()) + return input_patch.copy(),\ + deblur_patch.copy(),\ + hr_patch.copy() diff --git a/evaluation/.DS_Store b/evaluation/.DS_Store index 6e7bede..61fbeb9 100755 Binary files a/evaluation/.DS_Store and b/evaluation/.DS_Store differ diff --git a/evaluation/delete_image.m b/evaluation/delete_image.m index 7982cc4..92b8d5b 100755 --- a/evaluation/delete_image.m +++ b/evaluation/delete_image.m @@ -16,7 +16,9 @@ % http://xinyizhang.tech/bmvc2018 % https://github.com/jacquelinelala/GFN %% deleting -path = '/4TB/datasets/LR-GOPRO/Validation_4x/Results'; +function delete_image(folder) +path = fullfile(folder, 'Validation_4x/Results'); +%path = fullfile(folder, 'Validation_4x/HR'); result_dir = dir(fullfile(path, '*GFN_4x.png')); len = length(result_dir); diff --git a/evaluation/test_RGB.m b/evaluation/test_RGB.m index ccd6de5..818f881 100755 --- a/evaluation/test_RGB.m +++ b/evaluation/test_RGB.m @@ -1,5 +1,5 @@ % Description: -% -testting RGB channels PSNR & SSIM +% -testting RGB channels PSNR. % % Input: % - Validation/Results: some specific group images with limited endings. @@ -7,11 +7,11 @@ % % Output: % - PSNR Average PSNR -% - SSIM Average SSIM +% % Citation: % Gated Fusion Network for Joint Image Deblurring and Super-Resolution % The British Machine Vision Conference(BMVC2018 oral) -% Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai,?Fei Wang and?Ming-Hsuan Yang +% Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang % Thanks: % Many thanks to Wei-Sheng Lai al. for LapSRN. In this project we use % some codes from their project. @@ -22,34 +22,28 @@ % https://github.com/jacquelinelala/GFN %% testing +function test_RGB(folder) addpath(genpath('utils')); -results_path = '/4TB/datasets/LR-GOPRO/Validation_4x/Results'; -hr_path = '/4TB/datasets/LR-GOPRO/Validation_4x/HR'; +results_path = fullfile(folder, 'Validation_4x/Results'); +hr_path = fullfile(folder, 'Validation_4x/HR'); result_dir = dir(fullfile(results_path, '*GFN_4x.png')); hr_dir = dir(fullfile(hr_path, '*.png')); count = length(hr_dir); PSNR = zeros(count, 1); -SSIM = zeros(count, 1); IFC = zeros(count, 1); ifc = 0; scale = 4; - for i = 1 : count + fprintf("Calculating %s\n", hr_dir(i).name); HR = imread(fullfile(hr_dir(i).folder, hr_dir(i).name)); Results = imread(fullfile(result_dir(i).folder, result_dir(i).name)); - [PSNR(i), SSIM(i), IFC(i)] = evaluate_SR(HR, Results, scale, ifc); + [PSNR(i), IFC(i)] = evaluate_SR(HR, Results, scale, ifc); end PSNR(count + 1) = mean(PSNR(:)); -SSIM(count + 1) = mean(SSIM(:)); - fprintf("Average PSNR is %f\n", PSNR(count + 1)); -fprintf("Average SSIM is %f\n", SSIM(count + 1)); - -PSNR_path = fullfile('/4TB/datasets/LR-GOPRO/Validation_4x', 'PSNR-GFN_4x_HR.txt'); -SSIM_path = fullfile('/4TB/datasets/LR-GOPRO/Validation_4x', 'SSIM-GFN_4x_HR.txt'); +PSNR_path = fullfile(folder, 'Validation_4x', 'PSNR-GFN_4x_HR.txt'); save_matrix(PSNR, PSNR_path); -save_matrix(SSIM, SSIM_path); diff --git a/evaluation/test_bicubic.m b/evaluation/test_bicubic.m index 2e81c0c..13cb738 100755 --- a/evaluation/test_bicubic.m +++ b/evaluation/test_bicubic.m @@ -1,7 +1,7 @@ % ------------------------------------------------------------------------- % Description: % Use bicubic to upscale the input, and evaluate the results in terms -% of PSNR and SSIM (RGB channel) +% of PSNR. % % Input: % - Validation/LR_Blur : Blurry low-resolution input @@ -11,7 +11,7 @@ % - Validation/Results: images using bicubic upscaling and formatting % with 'Bic****.png' in Results directory % - PSNR: Average PSNR -% - SSIM: Average SSIM +% % Citation: % Gated Fusion Network for Joint Image Deblurring and Super-Resolution % The British Machine Vision Conference(BMVC2018 oral) @@ -26,10 +26,11 @@ % https://github.com/jacquelinelala/GFN %% testing +function test_bicubic(folder) addpath(genpath('utils')); -lr_blur_path = '/4TB/datasets/LR-GOPRO/Validation_4x/LR_Blur'; -hr_path = '/4TB/datasets/LR-GOPRO/Validation_4x/HR'; -results_path = '/4TB/datasets/LR-GOPRO/Validation_4x/Results'; +lr_blur_path = fullfile(folder, 'Validation_4x/LR_Blur'); +hr_path = fullfile(folder, 'Validation_4x/HR'); +results_path = fullfile(folder, 'Validation_4x/Results'); lr_blur_dir = dir(fullfile(lr_blur_path, '*.png')); hr_dir = dir(fullfile(hr_path, '*.png')); count = length(lr_blur_dir); @@ -45,17 +46,13 @@ LR_Blur = im2double(imread(fullfile(lr_blur_dir(i).folder, lr_blur_dir(i).name))); LR_Blur_Bic = imresize(LR_Blur, 4, 'bicubic'); imwrite(LR_Blur_Bic, fullfile(results_path, strcat(hr_dir(i).name(1:4), 'Bic.png')),'png'); - [PSNR(i), SSIM(i), IFC(i)] = evaluate_SR(HR, LR_Blur_Bic, scale, ifc); + [PSNR(i), IFC(i)] = evaluate_SR(HR, LR_Blur_Bic, scale, ifc); end PSNR(count + 1) = mean(PSNR(:)); -SSIM(count + 1) = mean(SSIM(:)); fprintf("Average PSNR is %f\n", PSNR(count + 1)); -fprintf("Average SSIM is %f\n", SSIM(count + 1)); -PSNR_path = fullfile('/4TB/datasets/LR-GOPRO/Validation_4x', 'PSNR-LRBlurBic_HR.txt'); -SSIM_path = fullfile('/4TB/datasets/LR-GOPRO/Validation_4x', 'SSIM-LRBlurBic_HR.txt'); +PSNR_path = fullfile(folder, 'Validation_4x', 'PSNR-LRBlurBic_HR.txt'); save_matrix(PSNR, PSNR_path); -save_matrix(SSIM, SSIM_path); diff --git a/evaluation/utils/.DS_Store b/evaluation/utils/.DS_Store index 379b718..e5cf285 100755 Binary files a/evaluation/utils/.DS_Store and b/evaluation/utils/.DS_Store differ diff --git a/evaluation/utils/IFC/distsub_est_M.m b/evaluation/utils/IFC/distsub_est_M.m deleted file mode 100755 index 3cfe611..0000000 --- a/evaluation/utils/IFC/distsub_est_M.m +++ /dev/null @@ -1,70 +0,0 @@ -function [g_all, vv_all]=vifsub_est_M(org,dist, subbands, M); - -% uses convolution for determining the parameters of the distortion channel -% Called by vifvec.m - -tol = 1e-15; % tolernace for zero variance. Variance below this is set to zero, and zero is set to this value to avoid numerical issues. - - -for i=1:length(subbands) - sub=subbands(i); - y=org{sub}; - yn=dist{sub}; - - % compute the size of the window used in the distortion channel estimation - lev=ceil((sub-1)/6); - winsize=2^lev+1; offset=(winsize-1)/2; - win = ones(winsize); - - % force subband size to be multiple of M - newsize=floor(size(y)./M)*M; - y=y(1:newsize(1),1:newsize(2)); - yn=yn(1:newsize(1),1:newsize(2)); - - % Correlation with downsampling. This is faster than downsampling after - % computing full correlation. - winstep=[M M]; - winstart=[1 1].*floor(M/2)+1; - winstop=size(y)-ceil(M/2)+1; - - % mean - mean_x = corrDn(y,win/sum(win(:)),'reflect1',winstep, winstart,winstop); - mean_y = corrDn(yn,win/sum(win(:)),'reflect1',winstep, winstart,winstop); - % cov - cov_xy = corrDn(y.*yn, win, 'reflect1',winstep, winstart,winstop) - sum(win(:)).*mean_x.*mean_y; - % var - ss_x = corrDn(y.^2,win, 'reflect1',winstep, winstart,winstop) - sum(win(:)).*mean_x.^2; - ss_y = corrDn(yn.^2,win, 'reflect1',winstep, winstart,winstop) - sum(win(:)).*mean_y.^2; - - - % get rid of numerical problems, very small negative numbers, or very - % small positive numbers, or other theoretical impossibilities. - ss_x(ss_x<0)=0; - ss_y(ss_y<0)=0; - - % Regression - g = cov_xy./(ss_x+tol); - - % Variance of error in regression - vv = (ss_y - g.*cov_xy)/(sum(win(:))); - - % get rid of numerical problems, very small negative numbers, or very - % small positive numbers, or other theoretical impossibilities. - g (ss_x < tol) = 0; - vv (ss_x < tol) = ss_y (ss_x < tol); - ss_x(ss_x 1 ) - img = rgb2ycbcr(img); - img = img(:, :, 1); - end - - img_list{i} = im2single(img); - end - -end \ No newline at end of file diff --git a/evaluation/utils/bilinear_kernel.m b/evaluation/utils/bilinear_kernel.m deleted file mode 100755 index e321064..0000000 --- a/evaluation/utils/bilinear_kernel.m +++ /dev/null @@ -1,42 +0,0 @@ -function f = bilinear_kernel(k, num_input, num_output) -% ------------------------------------------------------------------------- -% Description: -% create bilinear interpolation kernel for the convt (deconv) layer -% -% Input: -% - k : kernel size k x k -% - num_input : number of input channels -% - num_output : number of output channels -% -% Output: -% - f : bilinear filter -% -% Citation: -% Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution -% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang -% IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017 -% -% Contact: -% Wei-Sheng Lai -% wlai24@ucmerced.edu -% University of California, Merced -% ------------------------------------------------------------------------- - - - radius = ceil(k / 2); - - if rem(k, 2) == 1 - center = radius; - else - center = radius + 0.5; - end - - C = 1:k; - f = (ones(1, k) - abs(C - center) ./ radius)' ... - * (ones(1, k) - abs(C - center) ./ radius); - - f = repmat(f, 1, 1, num_input, num_output); - - -end - diff --git a/evaluation/utils/copy_model_weights.m b/evaluation/utils/copy_model_weights.m deleted file mode 100755 index b896fb5..0000000 --- a/evaluation/utils/copy_model_weights.m +++ /dev/null @@ -1,34 +0,0 @@ -function model = copy_model_weights(model, model_trained) -% ------------------------------------------------------------------------- -% Description: -% Copy the weights (parameters) of a pre-trained model to another -% model -% -% Input: -% - model : model to be initialized -% - model_trained : pre-trained model -% -% Output: -% - model : model with copied weights -% -% Citation: -% Fast and Accurate Image Super-Resolution with Deep Laplacian Pyramid Networks -% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang -% arXiv, 2017 -% -% Contact: -% Wei-Sheng Lai -% wlai24@ucmerced.edu -% University of California, Merced -% ------------------------------------------------------------------------- - - for i = 1:length(model.params) - - name = model.params(i).name; - idx = model_trained.getParamIndex(name); - model.params(i).value = model_trained.params(idx).value; - - end - - -end \ No newline at end of file diff --git a/evaluation/utils/count_network_parameters.m b/evaluation/utils/count_network_parameters.m deleted file mode 100755 index ff1e59b..0000000 --- a/evaluation/utils/count_network_parameters.m +++ /dev/null @@ -1,31 +0,0 @@ -function N = count_network_parameters(net) -% ------------------------------------------------------------------------- -% Description: -% Count the total number of network parameters -% -% Input: -% - net : network -% -% Output: -% - N : #parameters -% -% Citation: -% Fast and Accurate Image Super-Resolution with Deep Laplacian Pyramid Networks -% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang -% arXiv, 2017 -% -% Contact: -% Wei-Sheng Lai -% wlai24@ucmerced.edu -% University of California, Merced -% ------------------------------------------------------------------------- - - N = 0; - for i = 1:length(net.params) - - N = N + numel(net.params(i).value); - - end - - -end \ No newline at end of file diff --git a/evaluation/utils/evaluate_SR.m b/evaluation/utils/evaluate_SR.m index c52bbe5..a0b58c3 100755 --- a/evaluation/utils/evaluate_SR.m +++ b/evaluation/utils/evaluate_SR.m @@ -1,7 +1,7 @@ -function [PSNR, SSIM, IFC] = evaluate_SR(img_GT, img_HR, scale, compute_ifc) +function [PSNR, IFC] = evaluate_SR(img_GT, img_HR, scale, compute_ifc) % ------------------------------------------------------------------------- % Description: -% Compute PSNR, SSIM and IFC for SR +% Compute PSNR and IFC for SR % We convert RGB image to grayscale and crop boundaries for 'scale' % pixels % @@ -37,7 +37,7 @@ % evaluate PSNR = psnr(img_GT, img_HR); - SSIM = ssim(img_GT, img_HR); + %SSIM = ssim(img_GT, img_HR); %SSIM = 0; % comment IFC to speed up testing diff --git a/evaluation/utils/load_list.m b/evaluation/utils/load_list.m deleted file mode 100755 index 7b31252..0000000 --- a/evaluation/utils/load_list.m +++ /dev/null @@ -1,30 +0,0 @@ -function list = load_list(list_name) -% ------------------------------------------------------------------------- -% Description: -% load a list file that each row is a string/name -% -% Input: -% - list_name: file name of the list -% -% Output: -% - list : a cell array -% -% Citation: -% Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution -% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang -% IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017 -% -% Contact: -% Wei-Sheng Lai -% wlai24@ucmerced.edu -% University of California, Merced -% ------------------------------------------------------------------------- - - f = fopen(list_name); - if( f == -1 ) - error('%s does not exist!', list_name); - end - C = textscan(f, '%s', 'CommentStyle', '#'); - list = C{1}; - fclose(f); -end \ No newline at end of file diff --git a/evaluation/utils/matlabPyrTools/ChangeLog b/evaluation/utils/matlabPyrTools/ChangeLog deleted file mode 100755 index 04bf1f4..0000000 --- a/evaluation/utils/matlabPyrTools/ChangeLog +++ /dev/null @@ -1,478 +0,0 @@ - Log of changes made to matlabPyrTools code - (important changes marked with **) ------------------------------------------------------------------------ -2009-12-17 Eero Simoncelli - - * Made new tarfile (version 1.4) - - * imStats.m: Now also prints the skew. - -2009-12-17 Rob Young - - * Fixed compilePyrTools.m error messages by making individual - const mxArray arg variables. - -2009-12-17 Rob Young - - * Added compilePyrTools.m to the MEX directory, which takes care - of compiling all C files for the current platform. - -2009-12-17 Rob Young - - * Incorporated HTML versions of tutorials - -2005-07-01 Eero Simoncelli - - * Discovered that innerProd.c is now significantly slower than - just executing M'*M in matlab, due to speedups in recent versions - of matlab! So eliminated the MEX file, and the warning in - innerProd.m. Left innerProd.m behind for backward compatibility. - - -2005-05-04 Eero Simoncelli - - * Fixed blur.m to handle arbitrary size images - -2005-01-03 Eero Simoncelli - - * MEX/Makefile-linux: Added innerProd to Make files - -2004-11-28 Eero Simoncelli - - * blur.m (res): added missing arguments in call to upBlur. - -2004-10-27 Eero Simoncelli - - * mkGaussian.m: MEAN arg can now be 1D. - -2004-10-14 Eero Simoncelli - - * Made new tarfile (version 1.3) - - * Incorporated complex-valued steerable pyramid code (buildSCFpyr, - buildSCFpyrLevs,reconSCFpyr) written by Javier Portilla in 9/97, - and used in our work on texture representation/synthesis - (Portilla&Simoncelli, Int'l Journal of Computer Vision, - 40(1):49-71, Dec 2000). - - * Incorporated imGradient.m from personal code. - - * reagan.pgm out. feynam.pgm in - -2004-03-20 Eero Simoncelli - - * blur.m added (just calls blurDn and then upBlur). - -2003-08-06 Eero Simoncelli - - * blurDn.m (filt): Forced correct scaling of filters in 1D - -2003-05-28 Eero Simoncelli - - * incorporated setPyrBand.m from local code - -2002-10-01 Eero Simoncelli - - * incorporated clip.m from local code - -2002-09-18 Eero Simoncelli - - * pointOp.m: Added the new 'extrap' option for matlab's interp1 to - make this m-file version more compatible with the mex version. - -Wed Aug 28 2002 Eero Simoncelli - - * var2.m: now returns zero (instead of error) for matrix of size 1. - * function VECTORIZE renamed to VECTIFY, since it was colliding - with a function introduced in standard matlab. - -Dec 27 2001 Eero Simoncelli - - * Modified calls to upConv in reconSpyr.m and reconSpyrLevs.m so - that the returned result is bound. Previously, had relied on the - MEX version of upConv to destructively modify the result array, - users had been getting errors because they were using the m-file - version of upConv. - -Wed Sep 19 2001 Eero Simoncelli - - * buildSFpyrLevs/reconSFpyrLevs: replace use of "i" with sqrt(-1), to - avoid problems if user rebinds it! - -Wed Mar 28 10:22:01 2001 Eero Simoncelli - - * Moved innerProd.m and all associated MEX files from the - matlabLocal source tree into matlabPyrTools. - * Added innerProd to Contents.m - * Updated/clarified WARNINGS in all *.m files that have MEX versions. - -Tue Mar 27 11:21:53 2001 Eero Simoncelli - - * Incorporated Windows MEX files (*.dll) into MEX subdirectory. - Windows users should either copy these into the main directory, - or put the MEX subdirectory in their matlab path. - -Fri Mar 23 14:46:16 2001 Eero Simoncelli - - * buildSFpyrLevs.m, reconSFpyrLevs.m: shift the raised-cosine - lookup table (Xrcos) instead of incrementing the log-radial image - (log_rad). THis is more efficient... - -Fri Oct 1 19:37:03 1999 Eero Simoncelli - - * upConv.m: Did not return correct size result when STOP argument - was passed. Thanks to hertzman@mrl.nyu.edu for pointing this out. - -Fri Sep 17 15:53:26 1999 Eero Simoncelli - - * buildSFpyrLevs.m: Changed lutsize to 1024, giving a slight - increase in accuracy. - -Thu Feb 25 18:10:38 1999 Eero Simoncelli - - * histo1.m: Modified histo.m to be more compatible (but still not - exactly the same) as the MEX file version. - -Fri Jun 12 21:15:39 1998 Eero Simoncelli - - * TUTORIALS pyramids.m upgraded. - -Tue Feb 17 13:22:28 1998 Eero Simoncelli - - * showIm.m: Dims are now printed followed by the zoom factor. - -Mon Oct 13 14:49:51 1997 Eero Simoncelli - - * mkSquare.m: Modified to do raised-cosine soft threshold - transitions. - -Tue Oct 7 10:13:51 1997 Eero Simoncelli - - * upConv.m: Argument order was wrong (this function is not used - anyway, unless you don't compile the MEX code). - Thanks to - farid@psyche.mit.edu for pointing this out. - -Thu Sep 25 16:09:49 1997 Eero Simoncelli - - * MEX/wrap.c: Changed #include to , as - suggested by David Brainard. * Incorporated Mac-compiled mex - files, courtesy of David Brainard. - -Sat Sep 6 16:10:25 1997 Eero Simoncelli - - * MEX/convolve.h: abstracted out type of images with typedef image_type. - Added ansi declarations. - -Fri Aug 29 13:49:16 1997 Eero Simoncelli - - ** showIm.m: Modified to behave better under resizing (and printing): - resets axis units to "normalized". - -Thu Aug 28 22:56:52 1997 Eero Simoncelli - - ** MEX/edges.c: reflect1, reflect2, repeat, extend upgraded to work - properly for non-symmetric filters. reflect2 and extend were also - broken for upConv. Added qreflect2 to handle even-length QMF's - which broke under the reflect2 modification. - * Added example code to TUTORIALS/matlabPyrTools to illustrate the - boundary-handling behavior... - -Thu Aug 21 13:34:17 1997 Eero Simoncelli - - * var2, skew2, kurt2: modified to return complex values for complex images. - * imStats.m: now gives an error for complex args. - -Thu Aug 14 15:24:29 1997 Eero Simoncelli - - * Modified shift.m: negated the meaning of the offset parameter, - such that RES=shift(MTX,OFFSET) means RES(POS)=MTX(POS-OFFSET) - (this is more intuitive). - -Thu Jul 10 17:06:52 1997 Eero Simoncelli - - * Modified MEX/Makefile-* to be consistent with matlab5: - - call mex instead of cmex - - use -V4 flag (creating matlab v4 compatible binaries) - - * showIm.m (xlbl_offset): Modified to use "points" units, so that - printed images look correct. Still slightly busted for arbitrary figure - window sizes and for printing. - - * Modified upConv.c: does not return ANYTHING if you pass a result - argument (this had been causing occasional problems with matlab's - memory manager). - -Mon Jun 30 12:09:30 1997 Eero Simoncelli - - * reconSFpyr.m (res): now returns real part (oops). - - * reconSpyrLevs.m (maxLev): got rid of superfluous nbands argument - (can be calculated from bfilts). - -Mon May 26 12:29:54 1997 Eero Simoncelli - - * showIm.m/pgmWrite.m: Modified 'auto3'-scaling to use a - histogram. This gives a significant speedup. - - * fixed a few minor bugs in the TUTORIALS, having to do with - matching image sizes to the machine speed... - -Sat May 10 17:27:25 1997 Eero Simoncelli - - * pgmWrite.m: fixed auto-scaling bug. Added new scaling - calculations, parallel to those of imShow. - -Fri May 9 09:02:56 1997 Eero Simoncelli - - * buildSFpyr.m: Changed NBANDS argument to be ORDER, which is one - less than the number of orientation bands. This is consistent - with the derivative order, and the labels on the spNFilters files. - -Tue May 6 19:08:18 1997 Eero Simoncelli - - ** Added buildSFpyr, reconSFpyr: Steerable pyramids constructed - in the Fourier domain. Radial functions tile, with a - raised-cosine falloff. Angular functions are - cos(theta-k\pi/(K+1))^K, where K is the order (number of bands - minus 1). Compared to the convolution version: - + Reconstruction is exact (within floating point errors) - + Can produce any number of orientation bands. - - Typically slower. - - Boundary-handling must be circular. - Could be made much more efficient by taking advantage of symmetries in - the fft! - - * Added example usage of Fourier steerable pyramid to TUTORIALS/pyramids.m - - * steer.m: fixed for harmonic lists including zero. - -Sun May 4 15:16:10 1997 Eero Simoncelli - - * MEX/Makefile-linux: created. - - * spyrHt, spyrNumBands: Modified to return 0 for pyramids of height 0. - - * reconWpyr.m: utilize desctructive addition in calls to upConv. - - * reconSpyr.m: Added error check to ensure consistancy between - pyramid and filter file. Utilize destructive addition in upConv - call on highpass band. Modified to work properly with pyramids of - height 0. - -Mon Apr 28 13:38:10 1997 Eero Simoncelli - - * lplot.m: modified to handle complex vectors, use standard MatLab - indices, and show minimal axes. Added xrange parameter to allow - adjustment of X axis labeling. - -Sun Apr 27 20:20:41 1997 Eero Simoncelli - - * var2, skew2, kurt2: enhanced to work on complex matrices. - -Sat Apr 26 11:16:12 1997 Eero Simoncelli - - * Changed parent directory (and distribution) name: - matlabImTools -> matlabPyrTools - - * namedFilter.m: Added two more Daubechies filters, and modified - names to match the reference (e.g., daub2 is now a 4-tap filter). - - * Added vectorize.m: trivial function to pack matrix into vector (i.e., - computes mtx(:)). - - * Added upBlur.m: Upsample and blur (parallels blurDn). - -Sun Apr 13 14:23:38 1997 Eero Simoncelli - - * TUTORIALS/pyramids.m: Added plots of Fourier spectra for Wavelet bases. - - * make-tar-file: switched from compress to gzip for the - distribution tarfile. - - * namedFilter.m: Added a few even-length QMF's from Johnston80. - -Fri Apr 11 19:16:21 1997 Eero Simoncelli - - * buildWpyr.m, reconWpyr.m: Modified slightly, so that subsampling - lattice is better for even-length filters. - - * TUTORIALS/pyramids.m: Substantially overhauled. - -Thu Apr 10 15:20:23 1997 Eero Simoncelli - - * blurDn.m: added this function to downsample an image by a factor - 2^L. - - * Fixed minor bug in upConv.m: errors in image size checking. - -Mon Apr 7 13:25:37 1997 Eero Simoncelli - - * Changed TUTORIALS/matlabImTools.m to use histo.mex instead of - matlab's hist. - -Wed Apr 2 13:20:55 1997 Eero Simoncelli - - ** Incorporated Denis Pelli's ThinkC and MetroWorks projects for - Macintosh versions of the MEX code, along with MEX binaries. These - are included as an HQX'ed self-extracting archive - (Macintosh-MEX.sit.hqx), in the MEX subdirectory. - -Tue Apr 1 15:35:31 1997 Eero Simoncelli - - * edges.c: modified by Denis Pelli to support THINK C. * edges.c: - - * histo.c, upConv.c, corrDn.c: minor changes in error message - printouts, to work around bugs in THINK C. - - * Included Denis Pelli's MacReadMe file in the MEX subdirectory, - which gives instructions for MEX file compilation on a MacIntosh - (PPC or 68k). - - * wrap.c, convolve.c, edges.c: added explicit int function - declarations, and return values. - - * range2.m/range2.c: A MEX function for fast min/max computation. - Adjusted entropy2.m, histo.m, imStats.m, pgmWrite.m, showIm.m, - showLpyr.m, showSpyr.m, showWpyr.m to call it. - -Thu Mar 27 17:23:05 1997 Eero Simoncelli - - ** histo.m/histo.c: Added MEX function HISTO, a fast replacement - for matlab's HIST function. Modified histoMatch.m, entropy2.m to - call it. - - * Changed main directory name to matlabImTools. - - * Added TUTORIALS/README file. - -Wed Mar 19 14:19:51 1997 Eero Simoncelli - - * Changed directory name: MEX_SRC -> MEX - -Wed Mar 12 17:00:03 1997 Eero Simoncelli - - * mkGaussian.m: fixed another (X,Y) bug: both dimensions and - cov/mean are now specified in [y,x] order. - -Tue Mar 11 19:08:17 1997 Eero Simoncelli - - * showSpyr.m: Fixed a bug that was dropping display of one - orientation band when there were more than 2 of them! - -Mon Mar 10 19:08:24 1997 Eero Simoncelli - - * Added shift.m - - * makeSteerMtx -> steerDir2HarmMtx - - * Added TUTORIALS/matlab-EPS.m: examples using the code in this - distribution. - -Sun Mar 9 17:49:18 1997 Eero Simoncelli - - ** showIm.m: - - args: changed order so that NSHADES is last. - - TITLES: Can now pass a string for IM, which will be evaluated - in the global environment to get the matrix. The string is - used as a title. MATLAB v.5 ONLY!!! - - Added 'auto3' RANGE value, that scales based on percentiles. - THis is more robust to outliers than 'auto2' or 'auto1'. - - * pixelAxes.m: Made a more serious attempt to reverse-engineer - Mathworks' image pixelization. It is improved, but still makes - occasional errors. - - * Added skew2.m. - -Fri Mar 7 10:11:07 1997 Eero Simoncelli - - * pixelAxes.m: Modified to take an optional - ZOOM argument. Fixed dimension ordering bug - (positions are reported (x,y), but mtx dims are (y,x)!) - - * showIm.m: Added an optional ZOOM argument. - -Thu Mar 6 14:17:19 1997 Eero Simoncelli - - * Added showLpyr, showWpyr, showSpyr. Modified - TUTORIALS/pyramids.m to use them. - - * added pixelAxes.m: Adjusts size (in pixels) of currently - displayed image to be a multiple of the matrix dimensions, - thus eliminating display aliasing artifacts. - This is now called by all the "show" commands. - -Mon Mar 3 17:33:25 1997 Eero Simoncelli - - * Fixed bug in pgmWrite (dimensions were written in reverse order). - - * Fixed bug in showIm (X and Y coords were swapped on label display). - - * Fixed bug in reconLpyr (swapped X and Y coords on int_sz) - - * Changed calls to "reshape" to pass dimensions individually -- - older version of matlab do not accept the reshape(mtx,[y x]) form. - - * Fixed bug in mkDisc: sz a scalar. - - * Added ifftshift.m - -Fri Feb 28 11:07:20 1997 Eero Simoncelli - - * Re-worked TUTORIALS/pyramids.m - - * buildGpyr and buildLpyr now use 1+maxPyrHt for default height. - - * Fixed buildGpyr to work on 1D signals. - - ** Gaussian/Laplacian/Wavelet pyramid build and recon functions: - - work properly with new corrDn/upConv. - - use separable convolutions - - use destructive modification ability of upConv (less memory - allocation) - - * modulateFlipShift -> modulateFlip. - - * added lpyrHt, wpyrHt, spyrHt to return number of levels in a pyramid. - -Thu Feb 27 15:39:53 1997 Eero Simoncelli - - * Changed angular coordinate systems to CLOCKWISE in mkRamp, - mkTheta, mkSine, mkSquare. This is unnatural for screen viewing, - but consistent with an origin in the upper left corner of the - image, which is the way one addresses the underlying matrix. - - * mkSine and mkSquare can now take a frequency vector or the - period and direction args - -Tue Feb 25 11:58:33 1997 Eero Simoncelli - - ** Rewrote corrDn/upConv C routines: - - more efficient - - changed START parameters to have [1 1] origin, consistent with - matlab - - added STOP parameters - - upConv allows destructive modification of a result arg - - changed order of other params (sorry) - - wrote test file conv_test.m - * wrote zconv2.m - -Wed Aug 19 20:39:15 1996 Eero Simoncelli (eero@tarpon.cis.upenn.edu) - - ** Added "pointOp" function (MUCH faster than interp1). - ** Added "histoMatch" function. - -Fri Aug 2 00:56:31 1996 Eero Simoncelli (eero@tarpon.cis.upenn.edu) - - * Changed all function/file-names to be of the form "fooBar". * - Fixed entropy2.m (busted due to typo). - -Most matlab code was developed from 1992-1996, while the author was an -assistant professor of Computer and Information Science at University of -Pennsylvania. - -Original convolution code was written in Spring 1986, and comes from -OBVIUS (Object-Based Vision and Image Understanding System), an -interactive image-processing system written in Common Lisp (with calls -to C code). - diff --git a/evaluation/utils/matlabPyrTools/Contents.m b/evaluation/utils/matlabPyrTools/Contents.m deleted file mode 100755 index f9948f4..0000000 --- a/evaluation/utils/matlabPyrTools/Contents.m +++ /dev/null @@ -1,109 +0,0 @@ -% matlabPyrTools: Image and Multi-scale Pyramid Tools -% Version: 1.4, December-2009. -% Created: Early Spring, 1996. -% Author: Eero Simoncelli, eero.simoncelli@nyu.edu -% -% See README file for brief description. -% See ChangeLog file for latest modifications. -% See TUTORIALS subdirectory for demonstrations. -% Type "help matlabPyrTools" to see this file as documentation. -% Type "help " for documentation on individual commands. -% ----------------------------------------------------------------- -% Synthetic Images (matrices): -% mkImpulse - Make an image containing an impulse. -% mkRamp - Make an image containing a ramp function. -% mkR - Make an image containing distance from the origin. -% mkAngle - Make an image containing angle about origin. -% mkDisc - Make an image containing a disk image. -% mkGaussian - Make an image containing a Gaussian function. -% mkZonePlate - Make an image containing a zone plate (cos(r^2)). -% mkAngularSine - Make an image containing an angular sine wave (pinwheel). -% mkSine - Make an image containing a sine grating. -% mkSquare - Make an image containing a square grating. -% mkFract - Make an image containing fractal (1/f) noise. -% -% Point Operations: -% clip - clip values to a range. -% pointOp - Lookup table (much faster than interp1) [MEX file] -% histo - Efficient histogram computation [MEX file] -% histoMatch - Modify matrix elements to match specified histogram stats. -% -% Convolution (first two are significantly faster): -% corrDn - Correlate & downsample with boundary-handling [MEX file] -% upConv - Upsample & convolve with boundary-handling [MEX file] -% blurDn - Blur and subsample a signal/image. -% upBlur - Upsample and blur a signal/image. -% blur - Multi-scale blurring, calls blurDn and then upBlur. -% cconv2 - Circular convolution. -% rconv2 - Convolution with reflected boundaries. -% zconv2 - Convolution assuming zeros beyond image boundaries. -% -% General pyramids: -% pyrLow - Access lowpass subband from (any type of) pyramid -% pyrBand - Access a subband from (any type of) pyramid -% setPyrBand - Insert an image into (any type of) pyramid as a subband -% pyrBandIndices - Returns indices for given band in a pyramid vector -% maxPyrHt - compute maximum number of scales in a pyramid -% -% Gaussian/Laplacian Pyramids: -% buildGpyr - Build a Gaussian pyramid of an input signal/image. -% buildLpyr - Build a Laplacian pyramid of an input signal/image. -% reconLpyr - Reconstruct (invert) the Laplacian pyramid transform. -% -% Separable orthonormal QMF/wavelet Pyramids: -% buildWpyr - Build a separable wavelet representation of an input signal/image. -% reconWpyr - Reconstruct (invert) the wavelet transform. -% wpyrBand - Extract a single band of the wavelet representation. -% wpyrLev - Extract (packed) subbands at a particular level -% wpyrHt - Number of levels (height) of a wavelet pyramid. -% -% Steerable Pyramids: -% buildSpyr - Build a steerable pyramid representation of an input image. -% reconSpyr - Reconstruct (invert) the steerable pyramid transform. -% buildSFpyr - Build a steerable pyramid representation in the Fourier domain. -% reconSFpyr - Reconstruct (invert) the (Fourier domain) steerable pyramid transform. -% spyrBand - Extract a single band from a steerable pyramid. -% spyrHigh - Highpass residual band. -% spyrLev - A whole level (i.e., all images at a given scale) of a steerable pyramid. -% spyrHt - Number of levels (height) of a steerable pyramid. -% spyrNumBands - Number of orientation bands in a steerable pyramid. -% -% Steerable filters / derivatives: -% imGradient - Compute gradient of image using directionally accurete filters. -% steer - Steer filters (or responses). -% steer2HarmMtx - Construct a matrix mapping direcional basis to angular harmonics. -% -% Filters: -% binomialFilter - returns a filter of binomial coefficients. -% namedFilter - some typical Laplacian/Wavelet pyramid filters -% spNFilters - Set of Nth order steerable pyramid filters. -% derivNFiltersS - Matched set of S-tap 1D derivatives, orders 0 to N. -% -% Display: -% showIm - Display a matrix (real or complex) as grayscale image(s). -% Displays dimensions, subsampling, and range of pixel values. -% showLpyr - Display a Laplacian pyramid. -% showWpyr - Display a separable wavelet pyramid. -% showSpyr - Display a steerable pyramid. -% lplot - "lollipop" plot. -% nextFig - Make next figure window current. -% pixelAxes - Make image display use an integer number of pixels -% per sample to avoid resampling artifacts. -% -% Statistics (for 2D Matrices): -% range2 - Min and max of image (matrix) [MEX file] -% mean2 - Sample mean of an image (matrix). -% var2 - Sample variance of an image (matrix). -% skew2 - Sample skew (3rd moment / variance^1.5) of an image (matrix). -% kurt2 - Sample kurtosis (4th moment / variance^2) of an image (matrix). -% entropy2 - Sample entropy of an image (matrix). -% imStats - Report sample statistics of an image, or pair of images. -% -% Miscellaneous: -% pgmRead - Load a "pgm" image into a MatLab matrix [try einstein.pgm,feynman.pgm] -% pgmWrite - Write a MatLab matrix to a "pgm" image file. -% shift - circular shift a 2D matrix by an arbitrary amount. -% vectify - pack matrix into column vector (i.e., function to compute mtx(:)). -% ifftshift - inverse of MatLab's FFTSHIFT (differs for odd-length dimensions) -% rcosFn - return a lookup table of a raised-cosine threshold fn. -% innerProd - Compute M'*M efficiently (i.e., do not copy) [MEX file] diff --git a/evaluation/utils/matlabPyrTools/MEX/-MacReadMe b/evaluation/utils/matlabPyrTools/MEX/-MacReadMe deleted file mode 100755 index 898dc0c..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/-MacReadMe +++ /dev/null @@ -1 +0,0 @@ -MacReadMe How to compile a MEX file for Macintosh (Based on a similar note written by David Brainard and Denis Pelli to accompany the Psychophysics Toolbox.) A MEX file (short for "MATLAB extension") contains code that implements a new MATLAB function, allowing users to use the full power of the C language and the Macintosh hardware and operating system in implementing a new MATLAB function. This document explains how to produce a MEX file that is "fat" (i.e. will run as native code on both 68K and PowerPC Macs) and is compatible with both MATLAB 4 and 5. 1) To produce a MATLAB MEX file with PowerPC code you must have the Metrowerks CodeWarrior C compiler (version 10 or better, abbreviated as CW below). To produce 68K code we still use the Symantec THINK C compiler (version from Symantec C++ 8 CD-ROM release 5), but we will soon be switching to Metrowerks CodeWarrior. (See note A below.) 2) Place a copy of the MATLAB 4:Extern folder, supplied by Mathworks, on your compiler's search path. We suggest that you name the copy "MEX V4". (See notes B and C, below.) 3) Build any of the MEX files simply by opening its project file and asking your compiler to "Build Code Resource" (in THINK C) or to "Make" it (in CW). For each MEX file, e.g. histo.mex, there are two associated projects, e.g. histo.µ for CW, and histo.¹.4 for THINK C. To build a "fat" MEX, that runs native on both 68K and PowerPC, you should first compile in THINK C, and then in CW. (See note A, below.) Denis Pelli April 2, 1997 Notes A) The Mathworks support only the THINK C compiler to make 68K MEX code for MATLAB version 4 and only the CW compiler to make PPC MEX files for MATLAB 4 and both 68K and PPC for MATLAB 5. This archive includes THINK and CW projects. To build a fat MEX file for MATLAB 4, first "make" the THINK C version (e.g. histo.¹.4), producing a file with a .rsrc extension (e.g. histo.µ.rsrc). This is the 68K MEX file. When you then "make" histo.µ, the CW project incorporates the .rsrc file and generates a "fat" MEX file that will run native (i.e. fast) on both 68K and PowerPC. To make a 68K-only MEX file, simply rename, e.g., histo.µ.rsrc to histo.mex after you make the THINK project, and set the file type and creator to match the other MEX files. THINK C is slow and hard to work with. Symantec hasn't significantly upgraded in it many years. There is an error in the math.h header (version from Symantec C++ 8 CD-ROM release 5). We fix that error by some tricky preprocessor defines and undefines in the THINK C Prefix in each of the THINK projects. B) The easiest way to put a folder on your compilerÕs search path is simply to put the folder in the same folder as the compiler itself. If you want to use both CW and THINK C, then put the folder under CW, make an alias of it, and put the alias in THINK C's "Aliases" folder. C) Happily, MATLAB 5 is capable of running both V4 and V5 MEX files. Thus we are currently distributing sources that compile into V4 MEX files. The resulting MEX files run both under V4 and V5. In the future we will drop support for V4 and THINK C. (See note A above.) \ No newline at end of file diff --git a/evaluation/utils/matlabPyrTools/MEX/compilePyrTools.m b/evaluation/utils/matlabPyrTools/MEX/compilePyrTools.m deleted file mode 100755 index a4c8ed4..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/compilePyrTools.m +++ /dev/null @@ -1,15 +0,0 @@ -% This is a script file for compiling the mex versions of the Steerable -% Pyramid Tools. -% -% Usage:>> compilePyrTools -% -% Tested for gcc and lcc. -% -% Rob Young, 9/08 - -mex upConv.c convolve.c wrap.c edges.c -mex corrDn.c convolve.c wrap.c edges.c -mex histo.c -%mex innerProd.c -mex pointOp.c -mex range2.c diff --git a/evaluation/utils/matlabPyrTools/MEX/convolve.c b/evaluation/utils/matlabPyrTools/MEX/convolve.c deleted file mode 100755 index 60a11a4..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/convolve.c +++ /dev/null @@ -1,325 +0,0 @@ -/* -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; File: convolve.c -;;; Author: Eero Simoncelli -;;; Description: General convolution code for 2D images -;;; Creation Date: Spring, 1987. -;;; MODIFICATIONS: -;;; 10/89: approximately optimized the choice of register vars on SPARCS. -;;; 6/96: Switched array types to double float. -;;; 2/97: made more robust and readable. Added STOP arguments. -;;; 8/97: Bug: when calling internal_reduce with edges in {reflect1,repeat, -;;; extend} and an even filter dimension. Solution: embed the filter -;;; in the upper-left corner of a filter with odd Y and X dimensions. -;;; ---------------------------------------------------------------- -;;; Object-Based Vision and Image Understanding System (OBVIUS), -;;; Copyright 1988, Vision Science Group, Media Laboratory, -;;; Massachusetts Institute of Technology. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -*/ - -#include -#include -#include "convolve.h" - -/* - -------------------------------------------------------------------- - Correlate FILT with IMAGE, subsampling according to START, STEP, and - STOP parameters, with values placed into RESULT array. RESULT - dimensions should be ceil((stop-start)/step). TEMP should be a - pointer to a temporary double array the size of the filter. - EDGES is a string specifying how to handle boundaries -- see edges.c. - The convolution is done in 9 sections, where the border sections use - specially computed edge-handling filters (see edges.c). The origin - of the filter is assumed to be (floor(x_fdim/2), floor(y_fdim/2)). ------------------------------------------------------------------------- */ - -/* abstract out the inner product computation */ -#define INPROD(XCNR,YCNR) \ - { \ - sum=0.0; \ - for (im_pos=YCNR*x_dim+XCNR, filt_pos=0, x_filt_stop=x_fdim; \ - x_filt_stop<=filt_size; \ - im_pos+=(x_dim-x_fdim), x_filt_stop+=x_fdim) \ - for (; \ - filt_pos -#include - -#define ABS(x) (((x)>=0) ? (x) : (-(x))) -#define ROOT2 1.4142135623730951 -#define REDUCE 0 -#define EXPAND 1 -#define IS == -#define ISNT != -#define AND && -#define OR || - -typedef int (*fptr)(); - -typedef struct - { - char *name; - fptr func; - } EDGE_HANDLER; - -typedef double image_type; - -fptr edge_function(char *edges); -int internal_reduce(image_type *image, int x_idim, int y_idim, - image_type *filt, image_type *temp, int x_fdim, int y_fdim, - int x_start, int x_step, int x_stop, - int y_start, int y_step, int y_stop, - image_type *result, char *edges); -int internal_expand(image_type *image, - image_type *filt, image_type *temp, int x_fdim, int y_fdim, - int x_start, int x_step, int x_stop, - int y_start, int y_step, int y_stop, - image_type *result, int x_rdim, int y_rdim, char *edges); -int internal_wrap_reduce(image_type *image, int x_idim, int y_idim, - image_type *filt, int x_fdim, int y_fdim, - int x_start, int x_step, int x_stop, - int y_start, int y_step, int y_stop, - image_type *result); -int internal_wrap_expand(image_type *image, image_type *filt, int x_fdim, int y_fdim, - int x_start, int x_step, int x_stop, - int y_start, int y_step, int y_stop, - image_type *result, int x_rdim, int y_rdim); diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.c b/evaluation/utils/matlabPyrTools/MEX/corrDn.c deleted file mode 100755 index d02e272..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/corrDn.c +++ /dev/null @@ -1,145 +0,0 @@ -/* -RES = corrDn(IM, FILT, EDGES, STEP, START, STOP); - >>> See corrDn.m for documentation <<< - This is a matlab interface to the internal_reduce function. - EPS, 7/96. -*/ - -#define V4_COMPAT -#include /* Matlab matrices */ -#include - -#include "convolve.h" - -#define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) - -void mexFunction(int nlhs, /* Num return vals on lhs */ - mxArray *plhs[], /* Matrices on lhs */ - int nrhs, /* Num args on rhs */ - const mxArray *prhs[] /* Matrices on rhs */ - ) - { - double *image,*filt, *temp, *result; - int x_fdim, y_fdim, x_idim, y_idim; - int x_rdim, y_rdim; - int x_start = 1; - int x_step = 1; - int y_start = 1; - int y_step = 1; - int x_stop, y_stop; - const mxArray *arg0,*arg1,*arg3,*arg4; - double *mxMat; - char edges[15] = "reflect1"; - - if (nrhs<2) mexErrMsgTxt("requres at least 2 args."); - - /* ARG 1: IMAGE */ - arg0 = prhs[0]; - if notDblMtx(arg0) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix."); - image = mxGetPr(arg0); - x_idim = (int) mxGetM(arg0); /* X is inner index! */ - y_idim = (int) mxGetN(arg0); - - /* ARG 2: FILTER */ - arg1 = prhs[1]; - if notDblMtx(arg1) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix."); - filt = mxGetPr(arg1); - x_fdim = (int) mxGetM(arg1); - y_fdim = (int) mxGetN(arg1); - - if ((x_fdim > x_idim) || (y_fdim > y_idim)) - { - mexPrintf("Filter: [%d %d], Image: [%d %d]\n",x_fdim,y_fdim,x_idim,y_idim); - mexErrMsgTxt("FILTER dimensions larger than IMAGE dimensions."); - } - - /* ARG 3 (optional): EDGES */ - if (nrhs>2) - { - if (!mxIsChar(prhs[2])) - mexErrMsgTxt("EDGES arg must be a string."); - mxGetString(prhs[2],edges,15); - } - - /* ARG 4 (optional): STEP */ - if (nrhs>3) - { - arg3 = prhs[3]; - if notDblMtx(arg3) mexErrMsgTxt("STEP arg must be a double float matrix."); - if (mxGetM(arg3) * mxGetN(arg3) != 2) - mexErrMsgTxt("STEP arg must contain two elements."); - mxMat = mxGetPr(arg3); - x_step = (int) mxMat[0]; - y_step = (int) mxMat[1]; - if ((x_step<1) || (y_step<1)) - mexErrMsgTxt("STEP values must be greater than zero."); - } - - /* ARG 5 (optional): START */ - if (nrhs>4) - { - arg4 = prhs[4]; - if notDblMtx(arg4) mexErrMsgTxt("START arg must be a double float matrix."); - if (mxGetM(arg4) * mxGetN(arg4) != 2) - mexErrMsgTxt("START arg must contain two elements."); - mxMat = mxGetPr(arg4); - x_start = (int) mxMat[0]; - y_start = (int) mxMat[1]; - if ((x_start<1) || (x_start>x_idim) || - (y_start<1) || (y_start>y_idim)) - mexErrMsgTxt("START values must lie between 1 and the image dimensions."); - } - x_start--; /* convert from Matlab to standard C indexes */ - y_start--; - - /* ARG 6 (optional): STOP */ - if (nrhs>5) - { - if notDblMtx(prhs[5]) mexErrMsgTxt("STOP arg must be double float matrix."); - if (mxGetM(prhs[5]) * mxGetN(prhs[5]) != 2) - mexErrMsgTxt("STOP arg must contain two elements."); - mxMat = mxGetPr(prhs[5]); - x_stop = (int) mxMat[0]; - y_stop = (int) mxMat[1]; - if ((x_stopx_idim) || - (y_stopy_idim)) - mexErrMsgTxt("STOP values must lie between START and the image dimensions."); - } - else - { - x_stop = x_idim; - y_stop = y_idim; - } - - x_rdim = (x_stop-x_start+x_step-1) / x_step; - y_rdim = (y_stop-y_start+y_step-1) / y_step; - - /* mxFreeMatrix(plhs[0]); */ - plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_rdim,y_rdim,mxREAL); - if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); - result = mxGetPr(plhs[0]); - - temp = mxCalloc(x_fdim*y_fdim, sizeof(double)); - if (temp == NULL) - mexErrMsgTxt("Cannot allocate necessary temporary space"); - - /* - printf("i(%d, %d), f(%d, %d), r(%d, %d), X(%d, %d, %d), Y(%d, %d, %d), %s\n", - x_idim,y_idim,x_fdim,y_fdim,x_rdim,y_rdim, - x_start,x_step,x_stop,y_start,y_step,y_stop,edges); - */ - - if (strcmp(edges,"circular") == 0) - internal_wrap_reduce(image, x_idim, y_idim, filt, x_fdim, y_fdim, - x_start, x_step, x_stop, y_start, y_step, y_stop, - result); - else internal_reduce(image, x_idim, y_idim, filt, temp, x_fdim, y_fdim, - x_start, x_step, x_stop, y_start, y_step, y_stop, - result, edges); - - mxFree((char *) temp); - return; - } - - - diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexa64 b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexa64 deleted file mode 100755 index dad4651..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexglx b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexglx deleted file mode 100755 index 7a1decd..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmac b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmac deleted file mode 100755 index 75a5407..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmaci b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmaci deleted file mode 100755 index 77f4f4c..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmaci and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmaci64 b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmaci64 deleted file mode 100755 index 291afad..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexw32 b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexw32 deleted file mode 100755 index 5140651..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexw64 b/evaluation/utils/matlabPyrTools/MEX/corrDn.mexw64 deleted file mode 100755 index fef315c..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/corrDn.mexw64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/edges-orig.c b/evaluation/utils/matlabPyrTools/MEX/edges-orig.c deleted file mode 100755 index 1f6a98b..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/edges-orig.c +++ /dev/null @@ -1,494 +0,0 @@ -/* -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; File: edges.c -;;; Author: Eero Simoncelli -;;; Description: Boundary handling routines for use with convolve.c -;;; Creation Date: Spring 1987. -;;; MODIFIED, 6/96, to operate on double float arrays. -;;; MODIFIED by dgp, 4/1/97, to support THINK C. -;;; ---------------------------------------------------------------- -;;; Object-Based Vision and Image Understanding System (OBVIUS), -;;; Copyright 1988, Vision Science Group, Media Laboratory, -;;; Massachusetts Institute of Technology. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -*/ - -/* -This file contains functions which determine how edges are to be -handled when performing convolutions of images with linear filters. -Any edge handling function which is local and linear may be defined, -except (unfortunately) constants cannot be added. So to treat the -edges as if the image is surrounded by a gray field, you must paste it -into a gray image, convolve, and crop it out... -The main convolution function is called internal_filter and is defined -in the file convolve.c. The idea is that the convolution function -calls the edge handling function which computes a new filter based on -the old filter and the distance to the edge of the image. For -example, reflection is done by reflecting the filter through the -appropriate axis and summing. Currently defined functions are listed -below. -*/ - -/* -#define DEBUG -*/ - -#include -#include -#include -#include "convolve.h" - -#define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) ) -#define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) ) - -int reflect1(), reflect2(), repeat(), zero(), Extend(), nocompute(); -int ereflect(), predict(); - -/* Lookup table matching a descriptive string to the edge-handling function */ -#if !THINK_C - static EDGE_HANDLER edge_foos[] = - { - { "dont-compute", nocompute }, /* zero output for filter touching edge */ - { "zero", zero }, /* zero outside of image */ - { "repeat", repeat }, /* repeat edge pixel */ - { "reflect1", reflect1 }, /* reflect about edge pixels */ - { "reflect2", reflect2 }, /* reflect image, including edge pixels */ - { "extend", Extend }, /* extend (reflect & invert) */ - { "predict", predict }, /* predict based on portion covered by filt */ - { "ereflect", ereflect }, /* orthogonal QMF reflection */ - }; -#else - /* - This is really stupid, but THINK C won't allow initialization of static variables in - a code resource with string addresses. So we do it this way. - The 68K code for a MATLAB 4 MEX file can only be created by THINK C. - However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this - cludge can be dropped when we drop support for MATLAB 4. - Denis Pelli, 4/1/97. - */ - static EDGE_HANDLER edge_foos[8]; - - void InitializeTable(EDGE_HANDLER edge_foos[]) - { - static int i=0; - - if(i>0) return; - edge_foos[i].name="dont-compute"; - edge_foos[i++].func=nocompute; - edge_foos[i].name="zero"; - edge_foos[i++].func=zero; - edge_foos[i].name="repeat"; - edge_foos[i++].func=repeat; - edge_foos[i].name="reflect1"; - edge_foos[i++].func=reflect1; - edge_foos[i].name="reflect2"; - edge_foos[i++].func=reflect2; - edge_foos[i].name="extend"; - edge_foos[i++].func=Extend; - edge_foos[i].name="predict"; - edge_foos[i++].func=predict; - edge_foos[i].name="ereflect"; - edge_foos[i++].func=ereflect; - } -#endif - -/* -Function looks up an edge handler id string in the structure above, and -returns the associated function -*/ -fptr edge_function(char *edges) - { - int i; - -#if THINK_C - InitializeTable(edge_foos); -#endif - for (i = 0; i1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) ) - for (i=0; i0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); - int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - - for (i=0; i= 0) AND (y_res < filt_sz)) - for (x_filt=y_filt, x_res=x_start; - x_filt= 0) AND (x_res < x_dim)) - result[y_res+x_res] = filt[x_filt]; - return(0); - } - -/* -------------------------------------------------------------------- -repeat() - repeat edge pixel. Continuous, but content is usually -different from image. -*/ - -int repeat(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) - register double *filt, *result; - register int x_dim; - int y_dim, x_pos, y_pos, f_or_e; - { - register int y_filt,x_filt, y_res,x_res; - int filt_sz = x_dim*y_dim; - int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); - int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - - for (i=0; i=0)?((y_res=0)?((x_res0)?(x_dim-1):0; - register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; - int filt_sz = x_dim*y_dim; - int x_edge_dist = (x_pos>0)?(x_pos-x_dim-1):(x_pos+1); - int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim-1):(y_pos+1)); - int i; - - #ifdef DEBUG - printf("(%d,%d) ",y_pos,x_pos); - if (x_pos==0) printf("\n"); - #endif - - for (i=0; i0)?(x_dim-1):0; - register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; - int x_edge_dist = (x_pos>0)?(x_pos-x_dim):((x_pos<0)?(x_pos+1):0); - int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim):((y_pos<0)?(y_pos+1):0)); - int i; - int mx_pos = (x_dim/2)+1; - int my_pos = (y_dim/2)+1; - - #ifdef DEBUG - printf("(%d,%d) ",y_pos,x_pos); - if (x_pos==0) printf("\n"); - #endif - - for (i=0; i0)?(x_dim-1):0; - register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; - int x_edge_dist = (x_pos>0)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); - int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0)); - int i; - int mx_pos = (x_dim/2)+1; - int my_pos = (y_dim/2)+1; - - for (i=0; i0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); - int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - - for (i=0; i= 0) AND (y_res < filt_sz)) - for (x_filt=y_filt, x_res=x_start; - x_filt= 0) AND (x_res < x_dim)) - { - result[y_res+x_res] = filt[x_filt]; - taps_used += ABS(filt[x_filt]); - } - printf("TU: %f\n",taps_used); - if (f_or_e IS FILTER) - { - /* fraction = ( (double) filt_sz ) / ( (double) taps_used ); */ - for (i=0; i0)?(x_dim-1):0; - register int y_base = x_dim * ( (y_pos>0)?(y_dim-1):0 ); - int filt_sz = x_dim*y_dim; - int x_edge_dist = (x_pos>1)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); - int y_edge_dist = x_dim * ( (y_pos>1)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0) ); - int i; - double norm,onorm; - - for (i=0; i -#include -#include -#include "convolve.h" - -#define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) ) -#define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) ) - -int reflect1(), reflect2(), qreflect2(), repeat(), zero(), Extend(), nocompute(); -int ereflect(), predict(); - -/* Lookup table matching a descriptive string to the edge-handling function */ -#if !THINK_C - static EDGE_HANDLER edge_foos[] = - { - { "dont-compute", nocompute }, /* zero output for filter touching edge */ - { "zero", zero }, /* zero outside of image */ - { "repeat", repeat }, /* repeat edge pixel */ - { "reflect1", reflect1 }, /* reflect about edge pixels */ - { "reflect2", reflect2 }, /* reflect image, including edge pixels */ - { "qreflect2", qreflect2 }, /* reflect image, including edge pixels - for even-length QMF decompositions */ - { "extend", Extend }, /* extend (reflect & invert) */ - { "ereflect", ereflect }, /* orthogonal QMF reflection */ - }; -#else - /* - This is really stupid, but THINK C won't allow initialization of static variables in - a code resource with string addresses. So we do it this way. - The 68K code for a MATLAB 4 MEX file can only be created by THINK C. - However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this - cludge can be dropped when we drop support for MATLAB 4. - Denis Pelli, 4/1/97. - */ - static EDGE_HANDLER edge_foos[8]; - - void InitializeTable(EDGE_HANDLER edge_foos[]) - { - static int i=0; - - if(i>0) return; - edge_foos[i].name="dont-compute"; - edge_foos[i++].func=nocompute; - edge_foos[i].name="zero"; - edge_foos[i++].func=zero; - edge_foos[i].name="repeat"; - edge_foos[i++].func=repeat; - edge_foos[i].name="reflect1"; - edge_foos[i++].func=reflect1; - edge_foos[i].name="reflect2"; - edge_foos[i++].func=reflect2; - edge_foos[i].name="qreflect2"; - edge_foos[i++].func=qreflect2; - edge_foos[i].name="extend"; - edge_foos[i++].func=Extend; - edge_foos[i].name="ereflect"; - edge_foos[i++].func=ereflect; - } -#endif - -/* -Function looks up an edge handler id string in the structure above, and -returns the associated function -*/ -fptr edge_function(char *edges) - { - int i; - -#if THINK_C - InitializeTable(edge_foos); -#endif - for (i = 0; i1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) ) - for (i=0; i0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); - int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - - for (i=0; i= 0) AND (y_res < filt_sz)) - for (x_filt=y_filt, x_res=x_start; - x_filt= 0) AND (x_res < x_dim)) - result[y_res+x_res] = filt[x_filt]; - return(0); - } - - -/* -------------------------------------------------------------------- -reflect1() - Reflection through the edge pixels. Continuous, but -discontinuous first derivative. This is the right thing to do if you -are subsampling by 2, since it maintains parity (even pixels positions -remain even, odd ones remain odd). -*/ - -int reflect1(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) - register double *filt, *result; - register int x_dim; - int y_dim, x_pos, y_pos, r_or_e; - { - int filt_sz = x_dim*y_dim; - register int y_filt,x_filt, y_res, x_res; - register int x_base = (x_pos>0)?(x_dim-1):0; - register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); - int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); - int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); - int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); - - for (i=0; i y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - if ((x_overhang ISNT mx_pos) AND (x_pos ISNT 0)) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - } - if ((y_overhang ISNT my_pos) AND (y_pos ISNT 0)) - for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang; - y_filt > y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - if ((x_overhang ISNT mx_pos) AND (x_pos ISNT 0)) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - } - } - - return(0); - } - -/* -------------------------------------------------------------------- -reflect2() - Reflect image at boundary. The edge pixel is repeated, -then the next pixel, etc. Continuous, but discontinuous first -derivative. -*/ - -int reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) - register double *filt, *result; - register int x_dim; - int y_dim, x_pos, y_pos, r_or_e; - { - int filt_sz = x_dim*y_dim; - register int y_filt,x_filt, y_res, x_res; - register int x_base = (x_pos>0)?(x_dim-1):0; - register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); - int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); - int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); - int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); - - for (i=0; i0)?x_dim:0); - y_filt0)?1:0); - x_filt y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - if (x_pos ISNT 0) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - } - if (y_pos ISNT 0) - for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang-x_dim; - y_filt > y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - if (x_pos ISNT 0) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - } - } - - return(0); - } - - -/* -------------------------------------------------------------------- -qreflect2() - Modified version of reflect2 that works properly for -even-length QMF filters. -*/ - -int qreflect2(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) - double *filt, *result; - int x_dim, y_dim, x_pos, y_pos, r_or_e; - { - reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,0); - return(0); - } - -/* -------------------------------------------------------------------- -repeat() - repeat edge pixel. Continuous, with discontinuous first -derivative. -*/ - -int repeat(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) - register double *filt, *result; - register int x_dim; - int y_dim, x_pos, y_pos, r_or_e; - { - register int y_filt,x_filt, y_res,x_res, y_tmp, x_tmp; - register int x_base = (x_pos>0)?(x_dim-1):0; - register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); - int x_overhang = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); - int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int filt_sz = x_dim*y_dim; - int mx_pos = (x_dim/2); - int my_pos = x_dim * (y_dim/2); - int i; - - for (i=0; i=0)?((y_res=0)?((x_res y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - if ((x_base-x_overhang) ISNT mx_pos) - for (x_res=x_base, x_filt=x_base-ABS(x_overhang); - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - else /* ((x_base-x_overhang) IS mx_pos) */ - for (x_res=x_base, x_filt=x_base-ABS(x_overhang); - x_filt > x_base-x_dim; - x_filt--, x_res--) - for(x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_tmp)]; - else /* ((y_base-y_overhang) IS my_pos) */ - for (y_res=y_base, y_filt=y_base-ABS(y_overhang); - y_filt > y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - for (y_tmp=y_filt; y_tmp > y_base-filt_sz; y_tmp-=x_dim) - if ((x_base-x_overhang) ISNT mx_pos) - for (x_res=x_base, x_filt=x_base-ABS(x_overhang); - x_filt > x_base-x_dim; - x_filt--, x_res--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_tmp)+ABS(x_filt)]; - else /* ((x_base-x_overhang) IS mx_pos) */ - for (x_res=x_base, x_filt=x_base-ABS(x_overhang); - x_filt > x_base-x_dim; - x_filt--, x_res--) - for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_tmp)+ABS(x_tmp)]; - } /* End, if r_or_e IS EXPAND */ - - return(0); - } - -/* -------------------------------------------------------------------- -extend() - Extend image by reflecting and inverting about edge pixel -value. Maintains continuity in intensity AND first derivative (but -not higher derivs). -*/ - -int Extend(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) - register double *filt, *result; - register int x_dim; - int y_dim, x_pos, y_pos, r_or_e; - { - int filt_sz = x_dim*y_dim; - register int y_filt,x_filt, y_res,x_res, y_tmp, x_tmp; - register int x_base = (x_pos>0)?(x_dim-1):0; - register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); - int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); - int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); - int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); - int i; - - for (i=0; i=0) AND (y_res=0) AND (x_res=0) AND (x_res y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; - if (x_pos ISNT 0) - if (x_overhang ISNT mx_pos) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; - else /* x_overhang IS mx_pos */ - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; - x_filt > x_base-x_dim; - x_res--, x_filt--) - for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) - result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_filt)+ABS(x_tmp)]; - } - if (y_pos ISNT 0) - if (y_overhang ISNT my_pos) - for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang; - y_filt > y_base-filt_sz; - y_filt-=x_dim, y_res-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; - if ((x_pos ISNT 0) AND (x_overhang ISNT mx_pos)) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; - } - else /* y_overhang IS my_pos */ - for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang-x_dim; - y_filt > y_base-filt_sz; - y_res-=x_dim, y_filt-=x_dim) - for (y_tmp=y_filt; y_tmp > y_base-filt_sz; y_tmp-=x_dim) - { - for (x_res=x_base, x_filt=x_base-x_overhang; - x_filt > x_base-x_dim; - x_res--, x_filt--) - result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_tmp)+ABS(x_filt)]; - if ((x_pos ISNT 0) AND (x_overhang IS mx_pos)) - for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; - x_filt > x_base-x_dim; - x_res--, x_filt--) - for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) - result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_tmp)+ABS(x_tmp)]; - } - } /* r_or_e ISNT REDUCE */ - - return(0); - } - -/* -------------------------------------------------------------------- -predict() - Simple prediction. Like zero, but multiplies the result -by the reciprocal of the percentage of filter being used. (i.e. if -50% of the filter is hanging over the edge of the image, multiply the -taps being used by 2). */ - -int predict(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) - register double *filt, *result; - register int x_dim; - int y_dim, x_pos, y_pos, r_or_e; - { - register int y_filt,x_filt, y_res,x_res; - register double taps_used = 0.0; /* int *** */ - register double fraction = 0.0; - int filt_sz = x_dim*y_dim; - int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); - int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); - int i; - - for (i=0; i= 0) AND (y_res < filt_sz)) - for (x_filt=y_filt, x_res=x_start; - x_filt= 0) AND (x_res < x_dim)) - { - result[y_res+x_res] = filt[x_filt]; - taps_used += ABS(filt[x_filt]); - } - - if (r_or_e IS REDUCE) - { - /* fraction = ( (double) filt_sz ) / ( (double) taps_used ); */ - for (i=0; i0)?(x_dim-1):0; - register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); - int filt_sz = x_dim*y_dim; - int x_overhang = (x_pos>1)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); - int y_overhang = x_dim * ( (y_pos>1)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0) ); - int i; - double norm,onorm; - - for (i=0; i>> See histo.m for documentation <<< - EPS, ported from OBVIUS, 3/97. -*/ - -#define V4_COMPAT -#include /* Matlab matrices */ -#include - -#include /* NULL */ -#include /* ceil */ - -#define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) - -#define PAD 0.49999 /* A hair below 1/2, to avoid roundoff errors */ -#define MAXBINS 20000 - -void mexFunction(int nlhs, /* Num return vals on lhs */ - mxArray *plhs[], /* Matrices on lhs */ - int nrhs, /* Num args on rhs */ - const mxArray *prhs[] /* Matrices on rhs */ - ) - { - register double temp; - register int binnum, i, size; - register double *im, binsize; - register double origin, *hist, mn, mx, mean; - register int nbins; - double *bincenters; - const mxArray *arg0,*arg1,*arg2; - double *mxMat; - - if (nrhs < 1 ) mexErrMsgTxt("requires at least 1 argument."); - - /* ARG 1: MATRIX */ - arg0 = prhs[0]; - if notDblMtx(arg0) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); - im = mxGetPr(arg0); - size = (int) mxGetM(arg0) * mxGetN(arg0); - - /* FIND min, max, mean values of MTX */ - mn = *im; mx = *im; binsize = 0; - for (i=1; i mx) - mx = temp; - binsize += temp; - } - mean = binsize / size; - - /* ARG 3: BIN_CENTER */ - if (nrhs > 2) - { - arg2 = prhs[2]; - if notDblMtx(arg2) mexErrMsgTxt("BIN_CENTER arg must be a real scalar."); - if (mxGetM(arg2) * mxGetN(arg2) != 1) - mexErrMsgTxt("BIN_CENTER must be a real scalar."); - mxMat= mxGetPr(arg2); - origin = *mxMat; - } - else - origin = mean; - - /* ARG 2: If positive, NBINS. If negative, -BINSIZE. */ - if (nrhs > 1) - { - arg1 = prhs[1]; - if notDblMtx(arg1) mexErrMsgTxt("NBINS_OR_BINSIZE arg must be a real scalar."); - if (mxGetM(arg1) * mxGetN(arg1) != 1) - mexErrMsgTxt("NBINS_OR_BINSIZE must be a real scalar."); - mxMat= mxGetPr(arg1); - binsize = *mxMat; - } - else - { - binsize = 101; /* DEFAULT: 101 bins */ - } - - /* -------------------------------------------------- - Adjust origin, binsize, nbins such that - mx <= origin + (nbins-1)*binsize + PAD*binsize - mn >= origin - PAD*binsize - -------------------------------------------------- */ - if (binsize < 0) /* user specified BINSIZE */ - { - binsize = -binsize; - origin -= binsize * ceil((origin-mn-PAD*binsize)/binsize); - nbins = (int) ceil((mx-origin-PAD*binsize)/binsize) + 1; - } - else /* user specified NBINS */ - { - nbins = (int) (binsize + 0.5); /* round to int */ - if (nbins == 0) - mexErrMsgTxt("NBINS must be greater than zero."); - binsize = (mx-mn)/(nbins-1+2*PAD); /* start with lower bound */ - i = ceil((origin-mn-binsize/2)/binsize); - if ( mn < (origin-i*binsize-PAD*binsize) ) - binsize = (origin-mn)/(i+PAD); - else if ( mx > (origin+(nbins-1-i)*binsize+PAD*binsize) ) - binsize = (mx-origin)/((nbins-1-i)+PAD); - origin -= binsize * ceil((origin-mn-PAD*binsize)/binsize); - } - - if (nbins > MAXBINS) - { - mexPrintf("nbins: %d, MAXBINS: %d\n",nbins,MAXBINS); - mexErrMsgTxt("Number of histo bins has exceeded maximum"); - } - - /* Allocate hist and xvals */ - plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,nbins,mxREAL); - if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); - hist = mxGetPr(plhs[0]); - - if (nlhs > 1) - { - plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,nbins,mxREAL); - if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); - bincenters = mxGetPr(plhs[1]); - for (i=0, temp=origin; i= 0)) - (hist[binnum]) += 1.0; - else - printf("HISTO warning: value %f outside of range [%f,%f]\n", - im[i], origin-0.5*binsize, origin+(nbins-0.5)*binsize); - } - - return; - } - diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexa64 b/evaluation/utils/matlabPyrTools/MEX/histo.mexa64 deleted file mode 100755 index 284d740..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexglx b/evaluation/utils/matlabPyrTools/MEX/histo.mexglx deleted file mode 100755 index 4d67bfe..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexmac b/evaluation/utils/matlabPyrTools/MEX/histo.mexmac deleted file mode 100755 index 9c9d47a..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexmaci b/evaluation/utils/matlabPyrTools/MEX/histo.mexmaci deleted file mode 100755 index 9792435..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexmaci and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexmaci64 b/evaluation/utils/matlabPyrTools/MEX/histo.mexmaci64 deleted file mode 100755 index 7e399c6..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexw32 b/evaluation/utils/matlabPyrTools/MEX/histo.mexw32 deleted file mode 100755 index 03663ef..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/histo.mexw64 b/evaluation/utils/matlabPyrTools/MEX/histo.mexw64 deleted file mode 100755 index b1911cb..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/histo.mexw64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/innerProd.c b/evaluation/utils/matlabPyrTools/MEX/innerProd.c deleted file mode 100755 index 8fa1224..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/innerProd.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -RES = innerProd(MAT); - Computes mat'*mat - Odelia Schwartz, 8/97. -*/ - -#define V4_COMPAT -#include - -#include -#include -#include -#include -#include - -void mexFunction(int nlhs, /* Num return vals on lhs */ - mxArray *plhs[], /* Matrices on lhs */ - int nrhs, /* Num args on rhs */ - const mxArray *prhs[] /* Matrices on rhs */ - ) -{ - register double *res, *mat, tmp; - register int len, wid, i, k, j, jlen, ilen, imat, jmat; - mxArray *arg; - - /* get matrix input argument */ - /* should be matrix in which num rows >= num columns */ - arg=prhs[0]; - mat= mxGetPr(arg); - len = (int) mxGetM(arg); - wid = (int) mxGetN(arg); - if ( wid > len ) - printf("innerProd: Warning: width %d is greater than length %d.\n",wid,len); - plhs[0] = (mxArray *) mxCreateDoubleMatrix(wid,wid,mxREAL); - if (plhs[0] == NULL) - mexErrMsgTxt(sprintf("Error allocating %dx%d result matrix",wid,wid)); - res = mxGetPr(plhs[0]); - - for(i=0, ilen=0; i>> See pointOp.m for documentation <<< - EPS, ported from OBVIUS, 7/96. -*/ - -#define V4_COMPAT -#include /* Matlab matrices */ -#include - -#include /* NULL */ - -#define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) - -void internal_pointop(); - -void mexFunction(int nlhs, /* Num return vals on lhs */ - mxArray *plhs[], /* Matrices on lhs */ - int nrhs, /* Num args on rhs */ - const mxArray *prhs[] /* Matrices on rhs */ - ) - { - double *image, *lut, *res; - double origin, increment; - int x_dim, y_dim, lx_dim, ly_dim; - int warnings = 1; - const mxArray *arg0,*arg1,*arg2,*arg3,*arg4; - double *mxMat; - - if (nrhs < 4 ) mexErrMsgTxt("requres at least 4 args."); - - /* ARG 1: IMAGE */ - arg0 = prhs[0]; - if notDblMtx(arg0) mexErrMsgTxt("IMAGE arg must be a real non-sparse matrix."); - image = mxGetPr(arg0); - x_dim = (int) mxGetM(arg0); /* X is inner index! */ - y_dim = (int) mxGetN(arg0); - - /* ARG 2: Lookup table */ - arg1 = prhs[1]; - if notDblMtx(arg1) mexErrMsgTxt("LUT arg must be a real non-sparse matrix."); - lut = mxGetPr(arg1); - lx_dim = (int) mxGetM(arg1); /* X is inner index! */ - ly_dim = (int) mxGetN(arg1); - if ( (lx_dim != 1) && (ly_dim != 1) ) - mexErrMsgTxt("Lookup table must be a row or column vector."); - - /* ARG 3: ORIGIN */ - arg2 = prhs[2]; - if notDblMtx(arg2) mexErrMsgTxt("ORIGIN arg must be a real scalar."); - if (mxGetM(arg2) * mxGetN(arg2) != 1) - mexErrMsgTxt("ORIGIN arg must be a real scalar."); - mxMat = mxGetPr(arg2); - origin = *mxMat; - - /* ARG 4: INCREMENT */ - arg3 = prhs[3]; - if notDblMtx(arg3) mexErrMsgTxt("INCREMENT arg must be a real scalar."); - if (mxGetM(arg3) * mxGetN(arg3) != 1) - mexErrMsgTxt("INCREMENT arg must be a real scalar."); - mxMat = mxGetPr(arg3); - increment = *mxMat; - - /* ARG 5: WARNINGS */ - if (nrhs>4) - { - arg4 = prhs[4]; - if notDblMtx(arg4) mexErrMsgTxt("WARINGS arg must be a real scalar."); - if (mxGetM(arg4) * mxGetN(arg4) != 1) - mexErrMsgTxt("WARNINGS arg must be a real scalar."); - mxMat = mxGetPr(arg4); - warnings = (int) *mxMat; - } - - plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_dim,y_dim,mxREAL); - if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); - res = mxGetPr(plhs[0]); - - internal_pointop(image, res, x_dim*y_dim, lut, lx_dim*ly_dim, - origin, increment, warnings); - return; - } - - -/* Use linear interpolation on a lookup table. - Taken from OBVIUS. EPS, Spring, 1987. - */ -void internal_pointop (im, res, size, lut, lutsize, origin, increment, warnings) - register double *im, *res, *lut; - register double origin, increment; - register int size, lutsize, warnings; - { - register int i, index; - register double pos; - register int l_unwarned = warnings; - register int r_unwarned = warnings; - - lutsize = lutsize - 2; /* Maximum index value */ - if (increment > 0) - for (i=0; i lutsize) - { - index = lutsize; - if (r_unwarned) - { - mexPrintf("Warning: Extrapolating to right of lookup table...\n"); - r_unwarned = 0; - } - } - res[i] = lut[index] + (lut[index+1] - lut[index]) * (pos - index); - } - else - for (i=0; i - - - - - - - - - diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.c b/evaluation/utils/matlabPyrTools/MEX/range2.c deleted file mode 100755 index db0c204..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/range2.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -[MIN, MAX] = range2(MTX) - >>> See range2.m for documentation <<< - EPS, 3/97. -*/ - -#define V4_COMPAT -#include /* Matlab matrices */ -#include - -#include /* NULL */ - -#define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) - -void mexFunction(int nlhs, /* Num return vals on lhs */ - mxArray *plhs[], /* Matrices on lhs */ - int nrhs, /* Num args on rhs */ - const mxArray *prhs[] /* Matrices on rhs */ - ) - { - register double temp, mn, mx; - register double *mtx; - register int i, size; - const mxArray *arg; - - if (nrhs != 1) mexErrMsgTxt("requires 1 argument."); - - /* ARG 1: MATRIX */ - arg = prhs[0]; - if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); - mtx = mxGetPr(arg); - size = (int) mxGetM(arg) * mxGetN(arg); - - /* FIND min, max values of MTX */ - mn = *mtx; mx = *mtx; - for (i=1; i mx) - mx = temp; - } - - plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); - if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); - plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); - if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); - mtx = mxGetPr(plhs[0]); - mtx[0] = mn; - mtx = mxGetPr(plhs[1]); - mtx[0] = mx; - - return; - } - diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexa64 b/evaluation/utils/matlabPyrTools/MEX/range2.mexa64 deleted file mode 100755 index d50b913..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexglx b/evaluation/utils/matlabPyrTools/MEX/range2.mexglx deleted file mode 100755 index 7053170..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexmac b/evaluation/utils/matlabPyrTools/MEX/range2.mexmac deleted file mode 100755 index 8f32249..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexmaci b/evaluation/utils/matlabPyrTools/MEX/range2.mexmaci deleted file mode 100755 index 711d7f8..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexmaci and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexmaci64 b/evaluation/utils/matlabPyrTools/MEX/range2.mexmaci64 deleted file mode 100755 index ee259f6..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexw32 b/evaluation/utils/matlabPyrTools/MEX/range2.mexw32 deleted file mode 100755 index 513b195..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/range2.mexw64 b/evaluation/utils/matlabPyrTools/MEX/range2.mexw64 deleted file mode 100755 index ca4a261..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/range2.mexw64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.c b/evaluation/utils/matlabPyrTools/MEX/upConv.c deleted file mode 100755 index 98a2bec..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/upConv.c +++ /dev/null @@ -1,195 +0,0 @@ -/* -RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES); - >>> See upConv.m for documentation <<< - This is a matlab interface to the internal_expand function. - EPS, 7/96. -*/ - -#define V4_COMPAT -#include /* Matlab matrices */ -#include - -#include "convolve.h" - -#define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) - -void mexFunction(int nlhs, /* Num return vals on lhs */ - mxArray *plhs[], /* Matrices on lhs */ - int nrhs, /* Num args on rhs */ - const mxArray *prhs[] /* Matrices on rhs */ - ) - { - double *image,*filt, *temp, *result, *orig_filt; - int x_fdim, y_fdim, x_idim, y_idim; - int orig_x = 0, orig_y, x, y; - int x_rdim, y_rdim; - int x_start = 1; - int x_step = 1; - int y_start = 1; - int y_step = 1; - int x_stop, y_stop; - const mxArray *arg0,*arg1,*arg3,*arg4,*arg6; - double *mxMat; - char edges[15] = "reflect1"; - - if (nrhs<2) mexErrMsgTxt("requres at least 2 args."); - - /* ARG 1: IMAGE */ - arg0 = prhs[0]; - if notDblMtx(arg0) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix."); - image = mxGetPr(arg0); - x_idim = (int) mxGetM(arg0); /* X is inner index! */ - y_idim = (int) mxGetN(arg0); - - /* ARG 2: FILTER */ - arg1 = prhs[1]; - if notDblMtx(arg1) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix."); filt = mxGetPr(arg1); - x_fdim = (int) mxGetM(arg1); - y_fdim = (int) mxGetN(arg1); - - /* ARG 3 (optional): EDGES */ - if (nrhs>2) - { - if (!mxIsChar(prhs[2])) - mexErrMsgTxt("EDGES arg must be a string."); - mxGetString(prhs[2],edges,15); - } - - /* ARG 4 (optional): STEP */ - if (nrhs>3) - { - arg3 = prhs[3]; - if notDblMtx(arg3) mexErrMsgTxt("STEP arg must be double float matrix."); - if (mxGetM(arg3) * mxGetN(arg3) != 2) - mexErrMsgTxt("STEP arg must contain two elements."); - mxMat = mxGetPr(arg3); - x_step = (int) mxMat[0]; - y_step = (int) mxMat[1]; - if ((x_step<1) || (y_step<1)) - mexErrMsgTxt("STEP values must be greater than zero."); - } - - /* ARG 5 (optional): START */ - if (nrhs>4) - { - arg4 = prhs[4]; - if notDblMtx(arg4) mexErrMsgTxt("START arg must be double float matrix."); - if (mxGetM(arg4) * mxGetN(arg4) != 2) - mexErrMsgTxt("START arg must contain two elements."); - mxMat = mxGetPr(arg4); - x_start = (int) mxMat[0]; - y_start = (int) mxMat[1]; - if ((x_start<1) || (y_start<1)) - mexErrMsgTxt("START values must be greater than zero."); - } - x_start--; /* convert to standard C indexes */ - y_start--; - - /* ARG 6 (optional): STOP */ - if (nrhs>5) - { - if notDblMtx(prhs[5]) mexErrMsgTxt("STOP arg must be double float matrix."); - if (mxGetM(prhs[5]) * mxGetN(prhs[5]) != 2) - mexErrMsgTxt("STOP arg must contain two elements."); - mxMat = mxGetPr(prhs[5]); - x_stop = (int) mxMat[0]; - y_stop = (int) mxMat[1]; - if ((x_stop6) - { - arg6 = prhs[6]; - if notDblMtx(arg6) mexErrMsgTxt("RES arg must be double float matrix."); - - /* 7/10/97: Returning one of the args causes problems with Matlab's memory - manager, so we don't return anything if the result image is passed */ - /* plhs[0] = arg; */ - result = mxGetPr(arg6); - x_rdim = (int) mxGetM(arg6); /* X is inner index! */ - y_rdim = (int) mxGetN(arg6); - if ((x_stop>x_rdim) || (y_stop>y_rdim)) - mexErrMsgTxt("STOP values must within image dimensions."); - } - else - { - x_rdim = x_stop; - y_rdim = y_stop; - /* x_rdim = x_step * ((x_stop+x_step-1)/x_step); - y_rdim = y_step * ((y_stop+y_step-1)/y_step); */ - - plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_rdim,y_rdim,mxREAL); - if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); - result = mxGetPr(plhs[0]); - } - - if ( (((x_stop-x_start+x_step-1) / x_step) != x_idim) || - (((y_stop-y_start+y_step-1) / y_step) != y_idim) ) - { - mexPrintf("Im dims: [%d %d]\n",x_idim,y_idim); - mexPrintf("Start: [%d %d]\n",x_start,y_start); - mexPrintf("Step: [%d %d]\n",x_step,y_step); - mexPrintf("Stop: [%d %d]\n",x_stop,y_stop); - mexPrintf("Res dims: [%d %d]\n",x_rdim,y_rdim); - mexErrMsgTxt("Image sizes and upsampling args are incompatible!"); - } - - /* upConv has a bug for even-length kernels when using the - reflect1, extend, or repeat edge-handlers */ - if ((!strcmp(edges,"reflect1") || !strcmp(edges,"extend") || !strcmp(edges,"repeat")) - && - ((x_fdim%2 == 0) || (y_fdim%2 == 0))) - { - orig_filt = filt; - orig_x = x_fdim; - orig_y = y_fdim; - x_fdim = 2*(orig_x/2)+1; - y_fdim = 2*(orig_y/2)+1; - filt = mxCalloc(x_fdim*y_fdim, sizeof(double)); - if (filt == NULL) - mexErrMsgTxt("Cannot allocate necessary temporary space"); - for (y=0; y x_rdim) || (y_fdim > y_rdim)) - { - mexPrintf("Filter: [%d %d], ",x_fdim,y_fdim); - mexPrintf("Result: [%d %d]\n",x_rdim,y_rdim); - mexErrMsgTxt("FILTER dimensions larger than RESULT dimensions."); - } - - temp = mxCalloc(x_fdim*y_fdim, sizeof(double)); - if (temp == NULL) - mexErrMsgTxt("Cannot allocate necessary temporary space"); - - /* - printf("(%d, %d), (%d, %d), (%d, %d), (%d, %d), (%d, %d), %s\n", - x_idim,y_idim,x_fdim,y_fdim,x_rdim,y_rdim, - x_start,x_step,y_start,y_step,edges); - */ - - if (strcmp(edges,"circular") == 0) - internal_wrap_expand(image, filt, x_fdim, y_fdim, - x_start, x_step, x_stop, y_start, y_step, y_stop, - result, x_rdim, y_rdim); - else internal_expand(image, filt, temp, x_fdim, y_fdim, - x_start, x_step, x_stop, y_start, y_step, y_stop, - result, x_rdim, y_rdim, edges); - - if (orig_x) mxFree((char *) filt); - mxFree((char *) temp); - - return; - } - - - diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.exp b/evaluation/utils/matlabPyrTools/MEX/upConv.exp deleted file mode 100755 index 406461e..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.exp and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.lib b/evaluation/utils/matlabPyrTools/MEX/upConv.lib deleted file mode 100755 index 453f2e5..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.lib and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexa64 b/evaluation/utils/matlabPyrTools/MEX/upConv.mexa64 deleted file mode 100755 index f936b16..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexglx b/evaluation/utils/matlabPyrTools/MEX/upConv.mexglx deleted file mode 100755 index 3b12479..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexmac b/evaluation/utils/matlabPyrTools/MEX/upConv.mexmac deleted file mode 100755 index 98e7560..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexmaci b/evaluation/utils/matlabPyrTools/MEX/upConv.mexmaci deleted file mode 100755 index 9781561..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexmaci and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexmaci64 b/evaluation/utils/matlabPyrTools/MEX/upConv.mexmaci64 deleted file mode 100755 index b06df9a..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexw32 b/evaluation/utils/matlabPyrTools/MEX/upConv.mexw32 deleted file mode 100755 index 36d5011..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexw64 b/evaluation/utils/matlabPyrTools/MEX/upConv.mexw64 deleted file mode 100755 index be262d2..0000000 Binary files a/evaluation/utils/matlabPyrTools/MEX/upConv.mexw64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/MEX/upConv.mexw64.manifest b/evaluation/utils/matlabPyrTools/MEX/upConv.mexw64.manifest deleted file mode 100755 index 1c06b61..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/upConv.mexw64.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/evaluation/utils/matlabPyrTools/MEX/wrap.c b/evaluation/utils/matlabPyrTools/MEX/wrap.c deleted file mode 100755 index a081123..0000000 --- a/evaluation/utils/matlabPyrTools/MEX/wrap.c +++ /dev/null @@ -1,281 +0,0 @@ -/* -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; File: wrap.c -;;; Author: Eero Simoncelli -;;; Description: Circular convolution on 2D images. -;;; Creation Date: Spring, 1987. -;;; MODIFICATIONS: -;;; 6/96: Switched array types to double float. -;;; 2/97: made more robust and readable. Added STOP arguments. -;;; ---------------------------------------------------------------- -;;; Object-Based Vision and Image Understanding System (OBVIUS), -;;; Copyright 1988, Vision Science Group, Media Laboratory, -;;; Massachusetts Institute of Technology. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -*/ - -#include - -#include "convolve.h" - -/* - -------------------------------------------------------------------- - Performs correlation (i.e., convolution with filt(-x,-y)) of FILT - with IMAGE followed by subsampling (a.k.a. REDUCE in Burt&Adelson81). - The operations are combined to avoid unnecessary computation of the - convolution samples that are to be discarded in the subsampling - operation. The convolution is done in 9 sections so that mod - operations are not performed unnecessarily. The subsampling lattice - is specified by the START, STEP and STOP parameters. - -------------------------------------------------------------------- */ - -/* abstract out the inner product computation */ -#define INPROD(YSTART,YIND,XSTART,XIND) \ - { \ - sum=0.0; \ - for (y_im=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ - x_filt_stop<=filt_size; \ - y_im++, x_filt_stop+=x_fdim) \ - for (x_im=XSTART ; \ - filt_pos); - help matlabPyrTools - -A few functions are actually MEX interfaces to C code. These are -contained in the subdirectory called MEX. The MEX files have been -tested on Sun (Solaris), LinuX (on an Intel platform), and Macintosh -OSX (on PowerPC and Intel), but should not be difficult to compile on -most other platforms. Source code is included in the MEX directory, -as well as Make files. Pre-compiled versions are included for a -number of platforms. To compile on your platform, simply run -compilePyrTools.m which is located in the MEX subdirectory. - -To make sure these are in your matlab path, you can do *one* of the -following: - 1) Create a symbolic link (or macintosh "alias") for the relavent files - in the main matlabPyrTools directory, or - 2) Copy the relavent files into the main matlabPyrTools directory, or - 3) Put the MEX subdirectory in your matlab path: addpath('matlabPyrTools/MEX'); - -Some example script files showing usage of the code are in the -directory /TUTORIALS. There is a README file in that directory -describing the contents. - -Incremental changes/updates to the code are documented in the ChangeLog file. - -Comments/Suggestions/Bugs to: - Eero P. Simoncelli - Center for Neural Science, and - Courant Institute for Mathematical Sciences - New York University - eero.simoncelli@nyu.edu - http://www.cns.nyu.edu/~eero/ diff --git a/evaluation/utils/matlabPyrTools/TUTORIALS/HTML/lcv.css b/evaluation/utils/matlabPyrTools/TUTORIALS/HTML/lcv.css deleted file mode 100755 index 2f221f0..0000000 --- a/evaluation/utils/matlabPyrTools/TUTORIALS/HTML/lcv.css +++ /dev/null @@ -1,23 +0,0 @@ -BODY {margin-left:20; margin-top:5; margin-width:15; margin-height:5; font-family:helvetica,arial,sans-serif} - -P.titledlist {margin-left: 2.4em; text-indent: -2.4em; line-height: 1.3; -margin-top: 1.8ex; margin-bottom: 1.8ex;} - -P.people { margin-top: 0ex; margin-bottom: 0.6ex; margin-left: 12px; -text-indent: -12px; } - -P.research {margin-top: 1ex; margin-bottom: 1ex;} - -UL.compact {list-style-image:none; list-style: inside disc } - -LI.software {margin-top: 1ex; margin-bottom: 0ex;} - -a:link {text-decoration:none;} - -a:visited {text-decoration:none;} - -a:hover {color:blue; text-decoration:underline;} - -a span {display:none;} - -a:hover span {display:block; position:fixed; left:150px; padding:5px; background: #f0f0f0; border: 1px dotted #c0c0c0; opacity: 1;} diff --git a/evaluation/utils/matlabPyrTools/TUTORIALS/README b/evaluation/utils/matlabPyrTools/TUTORIALS/README deleted file mode 100755 index b8eb3ea..0000000 --- a/evaluation/utils/matlabPyrTools/TUTORIALS/README +++ /dev/null @@ -1,24 +0,0 @@ - -This directory contains some Matlab script files that serve to give -example usage of this code, and also to explain some of the -representations and algorithms. - -The files are NOT meant to be executed from the MatLab prompt (like many -of the MatLab demos). You should instead read through the comments, -executing the subsequent pieces of code. This gives you a chance to -explore as you go... - -matlabPyrTools.m - Example usage of the code in the distribution. - -pyramids.m - An introduction to multi-scale pyramid representations, - covering Laplacian, QMF/Wavelet, and Steerable pyramids. The - file assumes a knowledge of linear systems, matrix algebra, - and 2D Fourier transforms. - -matlabPyrTools.html - Same as matlabPyrTools.m, but formatted in html that - shows sample output. - -pyramids.html - Same as pyramids.m, but formatted in html that shows sample - output. - -more to come.... diff --git a/evaluation/utils/matlabPyrTools/TUTORIALS/matlabPyrTools.html b/evaluation/utils/matlabPyrTools/TUTORIALS/matlabPyrTools.html deleted file mode 100755 index 0d4c85c..0000000 --- a/evaluation/utils/matlabPyrTools/TUTORIALS/matlabPyrTools.html +++ /dev/null @@ -1,560 +0,0 @@ - - - - - - - - matlabPyrTools - - - - - - -
-

Some examples using the tools in this distribution.

-

Contents

- -

Load an image, and downsample to a size appropriate for the machine speed.

-
oim = pgmRead('einstein.pgm');
-tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc;
-imSubSample = min(max(floor(log2(time)/2+3),0),2);
-im = blurDn(oim, imSubSample,'qmf9');
-clear oim;
-
ShowIm: - 3 types of automatic graylevel scaling, 2 types of automatic - sizing, with or without title and Range information. -
help showIm
-
  RANGE = showIm (MATRIX, RANGE, ZOOM, LABEL, NSHADES )
-  
-  Display a MatLab MATRIX as a grayscale image in the current figure,
-  inside the current axes.  If MATRIX is complex, the real and imaginary 
-  parts are shown side-by-side, with the same grayscale mapping.
-  
-  If MATRIX is a string, it should be the name of a variable bound to a 
-  MATRIX in the base (global) environment.  This matrix is displayed as an 
-  image, with the title set to the string.
-  
-  RANGE (optional) is a 2-vector specifying the values that map to
-  black and white, respectively.  Passing a value of 'auto' (default)
-  sets RANGE=[min,max] (as in MatLab's imagesc).  'auto2' sets
-  RANGE=[mean-2*stdev, mean+2*stdev].  'auto3' sets
-  RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile
-  value of the sorted MATRIX samples, and p2 is the 90th percentile
-  value.
-  
-  ZOOM specifies the number of matrix samples per screen pixel.  It
-  will be rounded to an integer, or 1 divided by an integer.  A value
-  of 'same' or 'auto' (default) causes the zoom value to be chosen
-  automatically to fit the image into the current axes.  A value of
-  'full' fills the axis region (leaving no room for labels).  See
-  pixelAxes.m.
-  
-  If LABEL (optional, default = 1, unless zoom='full') is non-zero, the range 
-  of values that are mapped into the gray colormap and the dimensions 
-  (size) of the matrix and zoom factor are printed below the image.  If label 
-  is a string, it is used as a title.
-  
-  NSHADES (optional) specifies the number of gray shades, and defaults
-  to the size of the current colormap.
-
-
-
-clf; showIm(im,'auto1','auto','Al')
- -
-ans =
-
-     0   237
-
-
-
-clf; showIm('im','auto2')
- -
-ans =
-
-   33.5299  181.9745
-
-
-
-clf; showIm(im,'auto3',2)
-
-

-

-ans =
-
-   34.5314  161.4488
-
-
-Statistics:
mean2(im)
-var2(im)
-skew2(im)
-kurt2(im)
-entropy2(im)
-imStats(im)
-
-
-ans =
-
-  107.7522
-
-
-ans =
-
-   1.3772e+03
-
-
-ans =
-
-   -0.3853
-
-
-ans =
-
-    3.4430
-
-
-ans =
-
-    6.8841
-
-Image statistics:
-  Range: [0.000000, 237.000000]
-  Mean: 107.752213,  Stdev: 37.111143,  Kurtosis: 3.442999
-
-

Synthetic images. First pick some parameters:

-
-sz = 200;
-dir = 2*pi*rand(1)
-slope = 10*rand(1)-5
-int = 10*rand(1)-5;
-orig = round(1+(sz-1)*rand(2,1));
-expt = 0.8+rand(1)
-ampl = 1+5*rand(1)
-ph = 2*pi*rand(1)
-per = 20
-twidth = 7
-
-
-dir =
-
-    5.0015
-
-
-slope =
-
-   -4.3516
-
-
-expt =
-
-    1.1006
-
-
-ampl =
-
-    5.2370
-
-
-ph =
-
-    2.5244
-
-
-per =
-
-    20
-
-
-twidth =
-
-     7
-
-
-clf;
-showIm(mkRamp(sz,dir,slope,int,orig));
-
- -
-showIm(mkImpulse(sz,orig,ampl));
-
- -
-showIm(mkR(sz,expt,orig));
-
- -
-showIm(mkAngle(sz,dir));
-
- -
-showIm(mkDisc(sz,sz/4,orig,twidth));
-
- -
-showIm(mkGaussian(sz,(sz/6)^2,orig,ampl));
-
- -
-showIm(mkZonePlate(sz,ampl,ph));
-
- -
-showIm(mkAngularSine(sz,3,ampl,ph,orig));
-
- -
-showIm(mkSine(sz,per,dir,ampl,ph,orig));
-
- -
-showIm(mkSquare(sz,per,dir,ampl,ph,orig,twidth));
-
- -
-showIm(mkFract(sz,expt));
-
- -

Point operations (lookup tables):

[Xtbl,Ytbl] = rcosFn(20, 25, [-1 1]);
-plot(Xtbl,Ytbl);
-showIm(pointOp(mkR(100,1,[70,30]), Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0));
-
- - -

histogram Modification/matching:

[N,X] = histo(im, 150);
-[mn, mx] = range2(im);
-matched = histoMatch(rand(size(im)), N, X);
-showIm(im + sqrt(-1)*matched);
-[Nm,Xm] = histo(matched,150);
-nextFig(2,1);
-  subplot(1,2,1); plot(X,N); axis([mn mx 0 max(N)]);
-  subplot(1,2,2);  plot(Xm,Nm); axis([mn mx 0 max(N)]);
-nextFig(2,-1);
-
-
- -

Convolution routines:

-

Compare speed of convolution/downsampling routines:

noise = rand(400); filt = rand(10);
-tic; res1 = corrDn(noise,filt(10:-1:1,10:-1:1),'reflect1',[2 2]); toc;
-tic; ires = rconv2(noise,filt); res2 = ires(1:2:400,1:2:400); toc;
-imStats(res1,res2)
-
Elapsed time is 0.047516 seconds.
-Elapsed time is 0.445268 seconds.
-Difference statistics:
-  Range: [-2.486900e-14, 2.842171e-14]
-  Mean: 0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 302.015673
-

Display image and extension of left and top boundaries:

fsz = [9 9];
-fmid = ceil((fsz+1)/2);
-imsz = [16 16];
-
-% pick one:
-im = eye(imsz);
-im = mkRamp(imsz,pi/6);
-im = mkSquare(imsz,6,pi/6);
-
-% pick one:
-edges='reflect1';
-edges='reflect2';
-edges='repeat';
-edges='extend';
-edges='zero';
-edges='circular';
-edges='dont-compute';
-
-filt = mkImpulse(fsz,[1 1]);
-showIm(corrDn(im,filt,edges));
-line([0,0,imsz(2),imsz(2),0]+fmid(2)-0.5, ...
-     [0,imsz(1),imsz(1),0,0]+fmid(1)-0.5);
-title(sprintf('Edges = %s',edges));
-

Multi-scale pyramids (see pyramids.m for more examples, and explanations):

-

A Laplacian pyramid:

-
[pyr,pind] = buildLpyr(im);
-showLpyr(pyr,pind);
-
- -
-res = reconLpyr(pyr, pind); 		% full reconstruction
-imStats(im,res);			% essentially perfect
-
-
Difference statistics:
-  Range: [-1.110223e-16, 1.110223e-16]
-  Mean: 0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 328.192949
-
-
-res = reconLpyr(pyr, pind, [2 3]);  %reconstruct 2nd and 3rd levels only
-showIm(res);
-
- -

Wavelet/QMF pyramids:

-
filt = 'qmf9'; edges = 'reflect1';
-filt = 'haar'; edges = 'qreflect2';
-filt = 'qmf12'; edges = 'qreflect2';
-filt = 'daub3'; edges = 'circular';
-
-%[pyr,pind] = buildWpyr(im, 5-imSubSample, filt, edges);
-[pyr,pind] = buildWpyr(im, 'auto', filt, edges);
-showWpyr(pyr,pind,'auto2');
-
- -
-res = reconWpyr(pyr, pind, filt, edges);
-clf;
-showIm(im + i*res);
-imStats(im,res);
-
-
Difference statistics:
-  Range: [-1.419542e-11, 1.515488e-11]
-  Mean: 0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 225.129905
-
- -
-res = reconWpyr(pyr, pind, filt, edges, 'all', [2]);  %vertical only
-clf;
-showIm(res);
-
- -

Steerable pyramid:

%[pyr,pind] = buildSpyr(im,4-imSubSample,'sp3Filters');
-[pyr,pind] = buildSpyr(im,'auto','sp3Filters');
-showSpyr(pyr,pind);
-

Steerable pyramid, constructed in frequency domain:

%[pyr,pind] = buildSFpyr(im,5-imSubSample,4);  %5 orientation bands
-[pyr,pind] = buildSFpyr(im);  %5 orientation bands
-showSpyr(pyr,pind);
-res = reconSFpyr(pyr,pind);
-imStats(im,res);
-
Difference statistics:
-  Range: [-1.176482e-05, 1.176482e-05]
-  Mean: -0.000000,  Stdev (rmse): 0.000006,  SNR (dB): 102.665681
-
-
- - - \ No newline at end of file diff --git a/evaluation/utils/matlabPyrTools/TUTORIALS/matlabPyrTools.m b/evaluation/utils/matlabPyrTools/TUTORIALS/matlabPyrTools.m deleted file mode 100755 index cbdd881..0000000 --- a/evaluation/utils/matlabPyrTools/TUTORIALS/matlabPyrTools.m +++ /dev/null @@ -1,147 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Some examples using the tools in this distribution. -%%% Eero Simoncelli, 2/97. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%% Load an image, and downsample to a size appropriate for the machine speed. -oim = pgmRead('einstein.pgm'); -tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc; -imSubSample = min(max(floor(log2(time)/2+3),0),2); -im = blurDn(oim, imSubSample,'qmf9'); -clear oim; - -%%% ShowIm: -%% 3 types of automatic graylevel scaling, 2 types of automatic -%% sizing, with or without title and Range information. -help showIm -clf; showIm(im,'auto1','auto','Al') -clf; showIm('im','auto2') -clf; showIm(im,'auto3',2) - -%%% Statistics: -mean2(im) -var2(im) -skew2(im) -kurt2(im) -entropy2(im) -imStats(im) - -%%% Synthetic images. First pick some parameters: -sz = 200; -dir = 2*pi*rand(1) -slope = 10*rand(1)-5 -int = 10*rand(1)-5; -orig = round(1+(sz-1)*rand(2,1)); -expt = 0.8+rand(1) -ampl = 1+5*rand(1) -ph = 2*pi*rand(1) -per = 20 -twidth = 7 - -clf; -showIm(mkRamp(sz,dir,slope,int,orig)); -showIm(mkImpulse(sz,orig,ampl)); -showIm(mkR(sz,expt,orig)); -showIm(mkAngle(sz,dir)); -showIm(mkDisc(sz,sz/4,orig,twidth)); -showIm(mkGaussian(sz,(sz/6)^2,orig,ampl)); -showIm(mkZonePlate(sz,ampl,ph)); -showIm(mkAngularSine(sz,3,ampl,ph,orig)); -showIm(mkSine(sz,per,dir,ampl,ph,orig)); -showIm(mkSquare(sz,per,dir,ampl,ph,orig,twidth)); -showIm(mkFract(sz,expt)); - - -%%% Point operations (lookup tables): -[Xtbl,Ytbl] = rcosFn(20, 25, [-1 1]); -plot(Xtbl,Ytbl); -showIm(pointOp(mkR(100,1,[70,30]), Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0)); - - -%%% histogram Modification/matching: -[N,X] = histo(im, 150); -[mn, mx] = range2(im); -matched = histoMatch(rand(size(im)), N, X); -showIm(im + sqrt(-1)*matched); -[Nm,Xm] = histo(matched,150); -nextFig(2,1); - subplot(1,2,1); plot(X,N); axis([mn mx 0 max(N)]); - subplot(1,2,2); plot(Xm,Nm); axis([mn mx 0 max(N)]); -nextFig(2,-1); - -%%% Convolution routines: - -%% Compare speed of convolution/downsampling routines: -noise = rand(400); filt = rand(10); -tic; res1 = corrDn(noise,filt(10:-1:1,10:-1:1),'reflect1',[2 2]); toc; -tic; ires = rconv2(noise,filt); res2 = ires(1:2:400,1:2:400); toc; -imStats(res1,res2) - -%% Display image and extension of left and top boundaries: -fsz = [9 9]; -fmid = ceil((fsz+1)/2); -imsz = [16 16]; - -% pick one: -im = eye(imsz); -im = mkRamp(imsz,pi/6); -im = mkSquare(imsz,6,pi/6); - -% pick one: -edges='reflect1'; -edges='reflect2'; -edges='repeat'; -edges='extend'; -edges='zero'; -edges='circular'; -edges='dont-compute'; - -filt = mkImpulse(fsz,[1 1]); -showIm(corrDn(im,filt,edges)); -line([0,0,imsz(2),imsz(2),0]+fmid(2)-0.5, ... - [0,imsz(1),imsz(1),0,0]+fmid(1)-0.5); -title(sprintf('Edges = %s',edges)); - -%%% Multi-scale pyramids (see pyramids.m for more examples, -%%% and explanations): - -%% A Laplacian pyramid: -[pyr,pind] = buildLpyr(im); -showLpyr(pyr,pind); - -res = reconLpyr(pyr, pind); % full reconstruction -imStats(im,res); % essentially perfect - -res = reconLpyr(pyr, pind, [2 3]); %reconstruct 2nd and 3rd levels only -showIm(res); - -%% Wavelet/QMF pyramids: -filt = 'qmf9'; edges = 'reflect1'; -filt = 'haar'; edges = 'qreflect2'; -filt = 'qmf12'; edges = 'qreflect2'; -filt = 'daub3'; edges = 'circular'; - -%[pyr,pind] = buildWpyr(im, 5-imSubSample, filt, edges); -[pyr,pind] = buildWpyr(im, 'auto', filt, edges); -showWpyr(pyr,pind,'auto2'); - -res = reconWpyr(pyr, pind, filt, edges); -clf; -showIm(im + i*res); -imStats(im,res); - -res = reconWpyr(pyr, pind, filt, edges, 'all', [2]); %vertical only -clf; -showIm(res); - -%% Steerable pyramid: -%[pyr,pind] = buildSpyr(im,4-imSubSample,'sp3Filters'); -[pyr,pind] = buildSpyr(im,'auto','sp3Filters'); -showSpyr(pyr,pind); - -%% Steerable pyramid, constructed in frequency domain: -%[pyr,pind] = buildSFpyr(im,5-imSubSample,4); %5 orientation bands -[pyr,pind] = buildSFpyr(im); %5 orientation bands -showSpyr(pyr,pind); -res = reconSFpyr(pyr,pind); -imStats(im,res); diff --git a/evaluation/utils/matlabPyrTools/TUTORIALS/pyramids.html b/evaluation/utils/matlabPyrTools/TUTORIALS/pyramids.html deleted file mode 100755 index a663f36..0000000 --- a/evaluation/utils/matlabPyrTools/TUTORIALS/pyramids.html +++ /dev/null @@ -1,1701 +0,0 @@ - - - - - - - - pyramids - - - - - - - -

IMAGE PYRAMID TUTORIAL

-
- -A brief introduction to multi-scale pyramid decompositions for image processing. You should go through this, reading the comments, and -executing the corresponding MatLab instructions. This file assumes a basic familiarity with matrix algebra, with linear systems and Fourier -theory, and with MatLab. If you don't understand a particular function call, execute "help <functionName>" to see documentation. -
EPS, 6/96. -
Based on the original OBVIUS tutorial.

-Determine a subsampling factor for images, based on machine speed:

oim = pgmRead('einstein.pgm');
-tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc;
-imSubSample = min(max(floor(log2(time)/2+3),0),2);
-im = blurDn(oim, imSubSample,'qmf9');
-clear oim;
-clf; showIm(im, 'auto2', 'auto', 'im');
-
-
- -

LAPLACIAN PYRAMIDS:

-Images may be decomposed into information at different scales. Blurring eliminates the fine scales (detail):
binom5 = binomialFilter(5);
-lo_filt = binom5*binom5';
-blurred = rconv2(im,lo_filt);
-subplot(1,2,1); showIm(im, 'auto2', 'auto', 'im');
-subplot(1,2,2); showIm(blurred, 'auto2', 'auto', 'blurred');
-

-Subtracting the blurred image from the original leaves ONLY the fine scale detail:
fine0 = im - blurred;
-subplot(1,2,1); showIm(fine0, 'auto2', 'auto', 'fine0');
-

-The blurred and fine images contain all the information found in -the original image. Trivially, adding the blurred image to the -fine scale detail will reconstruct the original. We can compare -the original image to the sum of blurred and fine using the -"imStats" function, which reports on the statistics of the -difference between it's arguments: -
imStats(im, blurred+fine0);
-
Difference statistics:
-  Range: [-7.105427e-15, 3.552714e-15]
-  Mean: -0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 353.641098
-
-Since the filter is a lowpass filter, we might want to subsample - the blurred image. This may cause some aliasing (depends on the - filter), but the decomposition structure given above will still be - possible. The corrDn function correlates (same as convolution, but - flipped filter) and downsamples in a single operation (for - efficiency). The string 'reflect1' tells the function to handle - boundaries by reflecting the image about the edge pixels. Notice - that the blurred1 image is half the size (in each dimension) of the - original image. -
lo_filt = 2*binom5*binom5';  %construct a separable 2D filter
-blurred1 = corrDn(im,lo_filt,'reflect1',[2 2]);
-subplot(1,2,2); showIm(blurred1,'auto2','auto','blurred1');
-

-Now, to extract fine scale detail, we must interpolate the image - back up to full size before subtracting it from the original. The - upConv function does upsampling (padding with zeros between - samples) followed by convolution. This can be done using the - lowpass filter that was applied before subsampling or it can be - done with a different filter. -
fine1 = im - upConv(blurred1,lo_filt,'reflect1',[2 2],[1 1],size(im));
-subplot(1,2,1); showIm(fine1,'auto2','auto','fine1');
-

-We now have a technique that takes an image, computes two new - images (blurred1 and fine1) containing the coarse scale information - and the fine scale information. We can also (trivially) - reconstruct the original from these two (even if the subsampling of - the blurred1 image caused aliasing):
recon = fine1 + upConv(blurred1,lo_filt,'reflect1',[2 2],[1 1],size(im));
-imStats(im, recon);
-
Difference statistics:
-  Range: [-7.105427e-15, 7.105427e-15]
-  Mean: -0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 345.757412
-
-Thus, we have described an INVERTIBLE linear transform that maps an - input image to the two images blurred1 and fine1. The inverse - transformation maps blurred1 and fine1 to the result. This is - depicted graphically with a system diagram: -
IM --> blur/down2 ---------> BLURRED1 --> up2/blur --> add --> RECON
-|                    |                                  ^
-|	             |                                  |
-|	             V                                  |
-|	          up2/blur                              |
-|	             |                                  |
-|	             |                                  |
-|	             V                                  |
- --------------> subtract --> FINE1 -------------------
-Note that the number of samples in the representation (i.e., total - samples in BLURRED1 and FINE1) is 1.5 times the number of samples - in the original IM. Thus, this representation is OVERCOMPLETE. - Often, we will want further subdivisions of scale. We can - decompose the (coarse-scale) BLURRED1 image into medium coarse and - very coarse images by applying the same splitting technique: -
blurred2 = corrDn(blurred1,lo_filt,'reflect1',[2 2]);
-showIm(blurred2)
-
-
-ans =
-
-  152.6425  710.8401
-
- -
-fine2 = blurred1 - upConv(blurred2,lo_filt,'reflect1',[2 2],[1 1],size(blurred1));
-showIm(fine2)
-
-
-ans =
-
- -107.9813  151.5816
-
-
-
-Since blurred2 and fine2 can be used to reconstruct blurred1, and - blurred1 and fine1 can be used to reconstruct the original image, - the set of THREE images (also known as "subbands") {blurred2, - fine2, fine1} constitute a complete representation of the original - image. Note that the three subbands are displayed at the same size, - but they are actually three different sizes. -
subplot(1,3,1); showIm(fine1,'auto2',2^(imSubSample-1),'fine1');
-subplot(1,3,2); showIm(fine2,'auto2',2^(imSubSample),'fine2');
-subplot(1,3,3); showIm(blurred2,'auto2',2^(imSubSample+1),'blurred2');
-

-It is useful to consider exactly what information is stored in each - of the pyramid subbands. The reconstruction process involves - recursively interpolating these images and then adding them to the - image at the next finer scale. To see the contribution of ONE of - the representation images (say blurred2) to the reconstruction, we - imagine filling all the other subbands with zeros and then - following our reconstruction procedure. For the blurred2 subband, - this is equivalent to simply calling upConv twice: -
blurred2_full = upConv(upConv(blurred2,lo_filt,'reflect1',[2 2],[1 1],size(blurred1)),...
-    lo_filt,'reflect1',[2 2],[1 1],size(im));
-subplot(1,3,3); showIm(blurred2_full,'auto2',2^(imSubSample-1),'blurred2-full');
-

For the fine2 subband, this is equivalent to calling upConv once:

fine2_full = upConv(fine2,lo_filt,'reflect1',[2 2],[1 1],size(im));
-subplot(1,3,2); showIm(fine2_full,'auto2',2^(imSubSample-1),'fine2-full');
-

If we did everything correctly, we should be able to add together these three full-size images to reconstruct the original image:

recon = blurred2_full + fine2_full + fine1;
-imStats(im, recon)
-
-
-
Difference statistics:
-  Range: [-8.526513e-14, 5.684342e-14]
-  Mean: -0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 307.603254
-
- -

FUNCTIONS for CONSTRUCTING/MANIPULATING LAPLACIAN PYRAMIDS

-We can continue this process, recursively splitting off finer and finer details from the blurred image (like peeling off the outer layers of an onion). The resulting data structure is known as a "Laplacian Pyramid". To make things easier, we have written a MatLab function called buildLpyr to construct this object. The function returns two items: a long vector containing the subbands of the pyramid, and an index matrix that is used to access these subbands. The display routine showLpyr shows all the subbands of the pyramid, at the their correct relative sizes. It should now be clearer why these data structures are called "pyramids".

[pyr,pind] = buildLpyr(im,5-imSubSample);
-showLpyr(pyr,pind);
-

There are also "accessor" functions for pulling out a single subband:

showIm(pyrBand(pyr,pind,2));
-
-
-The reconLpyr function allows you to reconstruct from a laplacian pyramid. The third (optional) arg allows you to select any subset of pyramid bands (default is to use ALL of them).

clf; showIm(reconLpyr(pyr,pind,[1 3]),'auto2','auto','bands 1 and 3 only');
-
- -
-fullres = reconLpyr(pyr,pind);
-showIm(fullres,'auto2','auto','Full reconstruction');
-imStats(im,fullres);
-
Difference statistics:
-  Range: [-7.105427e-15, 7.105427e-15]
-  Mean: 0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 345.757510
-
-
buildLpyr uses 5-tap filters by default for building Laplacian pyramids. You can specify other filters:

namedFilter('binom3')
-[pyr3,pind3] = buildLpyr(im,5-imSubSample,'binom3');
-showLpyr(pyr3,pind3);
-fullres3 = reconLpyr(pyr3,pind3,'all','binom3');
-imStats(im,fullres3);
-
-ans =
-
-    0.3536
-    0.7071
-    0.3536
-
-Difference statistics:
-  Range: [, 7.105427e-15]
-  Mean: 0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 350.953606
-
-
Here we build a "Laplacian" pyramid using random filters. filt1 is used with the downsampling operations and filt2 is used with the upsampling operations. We normalize the filters for display purposes. Of course, these filters are (almost certainly) not very "Gaussian", and the subbands of such a pyramid will be garbage! Nevertheless, it is a simple property of the Laplacian pyramid that we can use ANY filters and we will still be able to reconstruct perfectly.

filt1 = rand(1,5); filt1 = sqrt(2)*filt1/sum(filt1)
-filt2 = rand(1,3); filt2 = sqrt(2)*filt2/sum(filt2)
-[pyrr,pindr] = buildLpyr(im,5-imSubSample,filt1,filt2);
-showLpyr(pyrr,pindr);
-fullresr = reconLpyr(pyrr,pindr,'all',filt2);
-imStats(im,fullresr);
-
-
-
-filt1 =
-
-    0.3708    0.2612    0.2453    0.4093    0.1276
-
-
-filt2 =
-
-    0.5662    0.5636    0.2845
-
-Difference statistics:
-  Range: [-1.421085e-14, 2.842171e-14]
-  Mean: -0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 336.260358
-
-

ALIASING in the Gaussian and Laplacian pyramids:

-Unless one is careful, the subsampling operations will introduce aliasing artifacts in these pyramid transforms. This is true even though the Laplacian pyramid can be used to reconstruct the original image perfectly. When reconstructing, the pyramid is designed in such a way that these aliasing artifacts cancel out. So it's not a problem if the only thing we want to do is reconstruct. However, it can be a serious problem if we intend to process each of the subbands independently. One way to see the consequences of the aliasing artifacts is byexamining variations that occur when the input is shifted. We choose an image and shift it by some number of pixels. Then blur -(filter-downsample-upsample-filter) the original image and blur the shifted image. If there's no aliasing, then the blur and shift operations should commute (i.e., shift-filter-downsample-upsample-filter is the same as filter-downsample-upsample-filter-shift). Try this for 2 different filters (by replacing 'binom3' with 'binom5' or 'binom7' below), and you'll see that the aliasing is much worse for the 3 tap filter.

sig = 100*randn([1 16]);
-sh = [0 7];  %shift amount
-lev = 2; % level of pyramid to look at
-flt = 'binom3';  %filter to use:
-
-shiftIm = shift(sig,sh);
-[pyr,pind] = buildLpyr(shiftIm, lev, flt, flt, 'circular');
-shiftBlur = reconLpyr(pyr, pind, lev, flt, 'circular');
-
-[pyr,pind] = buildLpyr(sig, lev, flt, flt, 'circular');
-res = reconLpyr(pyr, pind, lev, flt, 'circular');
-blurShift = shift(res,sh);
-
-subplot(2,1,1); r = showIm(shiftBlur,'auto2','auto','shiftBlur');
-subplot(2,1,2); showIm(blurShift,r,'auto','blurShift');
-imStats(blurShift,shiftBlur);
-
-
-
Difference statistics:
-  Range: [-9.191223e+01, 8.063398e+01]
-  Mean: 0.000000,  Stdev (rmse): 46.487369,  SNR (dB): -0.344851
-
-

PROJECTION and BASIS functions:

-An invertible, linear transform can be characterized in terms of a set of PROJECTION and BASIS functions. In matlab matrix notation:
-c = P' * x
-x = B * c
-where x is an input, c are the transform coefficients, P and B are matrices. The columns of P are the projection functions (the input is projected onto the the columns of P to get each successive transform coefficient). The columns of B are the basis functions (x is a linear combination of the columns of B). Since the Laplacian pyramid is a linear transform, we can ask: what are its BASIS functions? We consider these in one dimension for simplicity. The BASIS function corresponding to a given coefficient tells us how much that coefficient contributes to each pixel in the reconstructed image. We can construct a single basis -function by setting one sample of one subband equal to 1.0 (and all others to zero) and reconstructing. To build the entire matrix, we have to do this for every sample of every subband:

sz = min(round(48/(sqrt(2)^imSubSample)),36);
-sig = zeros(sz,1);
-[pyr,pind] = buildLpyr(sig);
-basis = zeros(sz,size(pyr,1));
-for n=1:size(pyr,1)
-  pyr = zeros(size(pyr));
-  pyr(n) = 1;
-  basis(:,n) = reconLpyr(pyr,pind);
-end
-clf; showIm(basis)
-
-ans =
-
-     0     1
-
-

The columns of the basis matrix are the basis functions. The matrix is short and fat, corresponding to the fact that the representation is OVERCOMPLETE. Below, we plot the middle one from each subband, starting with the finest scale. Note that all of these basis functions are lowpass (Gaussian-like) functions.

locations = round(sz * (2 - 3./2.^[1:max(4,size(pind,1))]))+1;
-for lev=1:size(locations,2)
-  subplot(2,2,lev);
-  showIm(basis(:,locations(lev)));
-  axis([0 sz 0 1.1]);
-end
-

Now, we'd also like see the inverse (we'll call them PROJECTION) functions. We need to ask how much of each sample of the input image contributes to a given pyramid coefficient. Thus, the matrix is constructed by building pyramids on the set of images with impulses at each possible location. The rows of this matrix are the projection functions.

projection = zeros(size(pyr,1),sz);
-for pos=1:sz
-  [pyr,pind] = buildLpyr(mkImpulse([1 sz], [1 pos]));
-  projection(:,pos) = pyr;
-end
-clf; showIm(projection);
-

Building a pyramid corresponds to multiplication by the projection matrix. Reconstructing from this pyramid corresponds to multiplication by the basis matrix. Thus, the product of the two matrices (in this order) should be the identity matrix:

showIm(basis*projection);
-

We can plot a few example projection functions at different scales. Note that all of the projection functions are bandpass functions, except for the coarsest subband which is lowpass.

for lev=1:size(locations,2)
-  subplot(2,2,lev);
-  showIm(projection(locations(lev),:));
-  axis([0 sz -0.3 0.8]);
-end
-

Now consider the frequency response of these functions, plotted over the range [-pi,pi]:

for lev=1:size(locations,2)
-  subplot(2,2,lev);
-  proj = projection(locations(lev),:);
-  plot(pi*[-32:31]/32,fftshift(abs(fft(proj',64))));
-  axis([-pi pi -0.1 3]);
-end
-

The first projection function is highpass, and the second is bandpass. Both of these look something like the Laplacian (2nd derivative) of a Gaussian. -The last is lowpass, as are the basis functions. Thus, the basic operation used to create each level of the pyramid involves a simple highpass/lowpass split.

-

QMF/WAVELET PYRAMIDS.

-Two things about Laplacian pyramids are a bit unsatisfactory.First, there are more pixels (coefficients) in the representation than in the original image. Specifically, the 1-dimensional transform is overcomplete by a factor of 4/3, and the 2-dimensional transform is overcomplete by a factor of 2. Secondly, the"bandpass" images (fineN) do not segregate information according toorientation.
There are other varieties of pyramid. One type that arose in the speech coding community is based on a particular pairs of filters known as a "Quadrature Mirror Filters" or QMFs. These are closely related to Wavelets (essentially, they are approximate wavelet -filters).
Recall that the Laplacian pyramid is formed by simple hi/low splitting at each level. The lowpass band is subsampled by a factor of 2, but the highpass band is NOT subsampled. In the QMF pyramid, we apply two filters (hi- and lo- pass) and subsample BOTH by a factor of 2, thus eliminating the excess coefficients of the Laplacian pyramid.
The two filters must have a specific relationship to each other. In particular, let n be an index for the filter samples. -The highpass filter may be constructed from the lowpass filter by (1) modulating (multiplying) by (-1)^n (equivalent to shifting by pi in the Fourier domain), (2) flipping (i.e., reversing the order of the taps), (3) spatially shifting by one sample. Try to convince yourself that the resulting filters will always be orthogonal to each other (i.e., their inner products will be zero) when shifted by any multiple of two.
The function modulateFlip performs the first two of these operations. The third (spatial shifting) step is built into the convolution code.

flo = namedFilter('qmf9')';
-fhi = modulateFlip(flo)';
-subplot(2,1,1); lplot(flo); axis([0 10 -0.5 1.0]); title('lowpass');
-subplot(2,1,2); lplot(fhi); axis([0 10 -0.5 1.0]); title('highpass');
-

In the Fourier domain, these filters are (approximately) "power-complementary": the sum of their squared power spectra is (approximately) a constant. But note that neither is a perfect bandlimiter (i.e., a sinc function), and thus subsampling by a factor of 2 will cause aliasing in each of the subbands. See below for a discussion of the effect of this aliasing. Plot the two frequency responses:

freq = pi*[-32:31]/32;
-subplot(2,1,1);
-plot(freq,fftshift(abs(fft(flo,64))),'--',freq,fftshift(abs(fft(fhi,64))),'-');
-axis([-pi pi 0 1.5]); title('FFT magnitudes');
-subplot(2,1,2);
-plot(freq,fftshift(abs(fft(flo,64)).^2)+fftshift(abs(fft(fhi,64)).^2));
-axis([-pi pi 0 2.2]); title('Sum of squared magnitudes');
-

We can split an input signal into two bands as follows:

sig = mkFract([1,64],1.6);
-subplot(2,1,1); showIm(sig,'auto1','auto','sig');
-lo1 = corrDn(sig,flo,'reflect1',[1 2],[1 1]);
-hi1 = corrDn(sig,fhi,'reflect1',[1 2],[1 2]);
-subplot(2,1,2);
-showIm(lo1,'auto1','auto','low and high bands'); hold on; plot(hi1,'--r'); hold off;
-

Notice that the two subbands are half the size of the original image, due to the subsampling by a factor of 2. One subtle point: the highpass and lowpass bands are subsampled on different lattices: the lowpass band retains the odd-numbered samples and the highpass band retains the even-numbered samples. This was the 1-sample shift relating the high and lowpass kernels (mentioned above). We've used the 'reflect1' to handle boundaries, which works properly for symmetric odd-length QMFs.
We can reconstruct the original image by interpolating these two subbands USING THE SAME FILTERS:

reconlo = upConv(lo1,flo,'reflect1',[1 2]);
-reconhi = upConv(hi1,fhi,'reflect1',[1 2],[1 2]);
-subplot(2,1,2); showIm(reconlo+reconhi,'auto1','auto','reconstructed');
-imStats(sig,reconlo+reconhi);
-
Difference statistics:
-  Range: [-1.832183e-03, 1.369161e-03]
-  Mean: -0.000062,  Stdev (rmse): 0.000727,  SNR (dB): 62.766134
-

We have described an INVERTIBLE linear transform that maps an input image to the two images lo1 and hi1. The inverse transformation maps these two images to the result. This is depicted graphically with a system diagram:
-
IM ---> flo/down2 --> LO1 --> up2/flo --> add --> RECON
-    |                                      ^
-    |	                                   |
-    |	                                   |
-     -> fhi/down2 --> HI1 --> up2/fhi -----

-Note that the number of samples in the representation (i.e., total samples in LO1 and HI1) is equal to the number of samples in the original IM. Thus, this representation is exactly COMPLETE, or "critically sampled".
So we've fixed one of the problems that we had with Laplacian pyramid. But the system diagram above places strong constraints on the filters. In particular, for these filters the reconstruction is no longer perfect. Turns out there are NO perfect-reconstruction symmetric filters that are power-complementary, except for the trivial case [1] and the nearly-trivial case [1 1]/sqrt(2).
Let's consider the projection functions of this 2-band splitting operation. We can construct these by applying the transform to impulse input signals, for all possible impulse locations. The rows of the following matrix are the projection functions for each coefficient in the transform.

M = [corrDn(eye(32),flo','circular',[1 2]), ...
-     corrDn(eye(32),fhi','circular',[1 2],[1 2])]';
-clf; showIm(M,'auto1','auto','M');
-

The transform matrix is composed of two sub-matrices. The top half contains the lowpass kernel, shifted by increments of 2 samples. The bottom half contains the highpass. Now we compute the inverse of this matrix:

M_inv = inv(M);
-showIm(M_inv,'auto1','auto','M_inv');
-

The inverse is (very close to) the transpose of the original matrix! In other words, the transform is orthonormal.

imStats(M_inv',M);
-
Difference statistics:
-  Range: [-6.479123e-04, 3.974265e-04]
-  Mean: -0.000004,  Stdev (rmse): 0.000263,  SNR (dB): 56.495757
-

This also points out a nice relationship between the corrDn and upConv functions, and the matrix representation. corrDn is equivalent to multiplication by a matrix with copies of the filter on the ROWS, translated in multiples of the downsampling factor. upConv is equivalent to multiplication by a matrix with copies of the filter on the COLUMNS, translated by the upsampling factor. As in the Laplacian pyramid, we can recursively apply this QMF band-splitting operation to the lowpass band:

lo2 = corrDn(lo1,flo,'reflect1',[1 2]);
-hi2 = corrDn(lo1,fhi,'reflect1',[1 2],[1 2]);
-

The representation of the original signal is now comprised of the three subbands {hi1, hi2, lo2} (we don't hold onto lo1, because it can be reconstructed from lo2 and hi2). Note that hi1 is at 1/2 resolution, and hi2 and lo2 are at 1/4 resolution: The total number of samples in these three subbands is thus equal to the number of samples in the original signal.

imnames=['hi1'; 'hi2'; 'lo2'];
-for bnum=1:3
-  band = eval(imnames(bnum,:));
-  subplot(3,1,bnum); showIm(band); ylabel(imnames(bnum,:));
-  axis([1 size(band,2) 1.1*min(lo2) 1.1*max(lo2)]);
-end
-

Reconstruction proceeds as with the Laplacian pyramid: combine lo2 and hi2 to reconstruct lo1, which is then combined with hi1 to reconstruct the original signal:

-
recon_lo1 = upConv(hi2,fhi,'reflect1',[1 2],[1 2]) + ...
-            upConv(lo2,flo,'reflect1',[1 2],[1 1]);
-reconstructed = upConv(hi1,fhi,'reflect1',[1 2],[1 2]) + ...
-                upConv(recon_lo1,flo,'reflect1',[1 2],[1 1]);
-imStats(sig,reconstructed);
-
-
-
Difference statistics:
-  Range: [-2.857375e-03, 1.844433e-03]
-  Mean: -0.000097,  Stdev (rmse): 0.001304,  SNR (dB): 57.694286
-
- -

FUNCTIONS for CONSTRUCTING/MANIPULATING QMF/Wavelet PYRAMIDS

-To make things easier, we have bundled these qmf operations and data structures into an object in MATLAB.

-
sig = mkFract([1 64], 1.5);
-[pyr,pind] = buildWpyr(sig);
-showWpyr(pyr,pind);
-
- -
-nbands = size(pind,1);
-for b = 1:nbands
-  subplot(nbands,1,b); lplot(pyrBand(pyr,pind,b));
-end
-
-res = reconWpyr(pyr,pind);
-imStats(sig,res);
-
Difference statistics:
-  Range: [-4.206845e-03, 3.766628e-03]
-  Mean: -0.000445,  Stdev (rmse): 0.001764,  SNR (dB): 55.072026
-

Now for 2D, we use separable filters. There are 4 ways to apply the two filters to the input image (followed by the relavent subsampling operation):
-(1) lowpass in both x and y
-(2) lowpass in x and highpass in y
-(3) lowpass in y and highpass in x
-(4) highpass in both x and y.
-The pyramid is built by recursively subdividing the first of these bands into four new subbands.
-First, we'll take a look at some of the basis functions.

sz = 40;
-zim = zeros(sz);
-flo = 'qmf9'; edges = 'reflect1';
-[pyr,pind] = buildWpyr(zim);
-
-% Put an  impulse into the middle of each band:
-for lev=1:size(pind,1)
-  mid = sum(prod(pind(1:lev-1,:)'));
-  mid = mid + floor(pind(lev,2)/2)*pind(lev,1) + floor(pind(lev,1)/2) + 1;
-  pyr(mid,1) = 1;
-end
-
-% And take a look at the reconstruction of each band:
-for lnum=1:wpyrHt(pind)+1
-  for bnum=1:3
-    subplot(wpyrHt(pind)+1,3,(wpyrHt(pind)+1-lnum)*3+bnum);
-    showIm(reconWpyr(pyr, pind, flo, edges, lnum, bnum),'auto1',2,0);
-  end
-end
-

Note that the first column contains horizontally oriented basis functions at different scales. The second contains vertically oriented basis functions. -The third contains both diagonals (a checkerboard pattern). The bottom row shows (3 identical images of) a lowpass basis function. Now look at the corresponding Fourier transform magnitudes (these are plotted over the frequency range [-pi, pi] ):

nextFig(2,1);
-freq = 2 * pi * [-sz/2:(sz/2-1)]/sz;
-for lnum=1:wpyrHt(pind)+1
-  for bnum=1:3
-    subplot(wpyrHt(pind)+1,3,(wpyrHt(pind)+1-lnum)*3+bnum);
-    basisFn = reconWpyr(pyr, pind, flo, edges, lnum, bnum);
-    basisFmag = fftshift(abs(fft2(basisFn,sz,sz)));
-    imagesc(freq,freq,basisFmag);
-    axis('square'); axis('xy'); colormap('gray');
-  end
-end
-nextFig(2,-1);
-

The filters at a given scale sum to a squarish annular region:

sumSpectra = zeros(sz);
-lnum = 2;
-for bnum=1:3
-  basisFn = reconWpyr(pyr, pind, flo, edges, lnum, bnum);
-  basisFmag = fftshift(abs(fft2(basisFn,sz,sz)));
-  sumSpectra = basisFmag.^2 + sumSpectra;
-end
-clf; imagesc(freq,freq,sumSpectra); axis('square'); axis('xy'); title('one scale');
-

Now decompose an image:

-
[pyr,pind] = buildWpyr(im);
-

View all of the subbands (except lowpass), scaled to be the same size (requires a big figure window):

scrsz = get(0,'ScreenSize');
-figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2])
-
-nlevs = wpyrHt(pind);
-for lnum=1:nlevs
-  for bnum=1:3
-    subplot(nlevs,3,(lnum-1)*3+bnum);
-    showIm(wpyrBand(pyr,pind,lnum,bnum), 'auto2', 2^(lnum+imSubSample-2));
-  end
-end
-

In addition to the bands shown above, there's a lowpass residual:

-
nextFig(2,1);
-clf; showIm(pyrLow(pyr,pind));
-nextFig(2,-1);
-
- -
-% Alternatively, display the pyramid with the subbands shown at their
-% correct relative sizes:
-clf; showWpyr(pyr, pind);
-
-
The reconWpyr function can be used to reconstruct the entire pyramid:

reconstructed = reconWpyr(pyr,pind);
-imStats(im,reconstructed);
-
Difference statistics:
-  Range: [-4.394200e-01, 3.481599e-01]
-  Mean: -0.144226,  Stdev (rmse): 0.071076,  SNR (dB): 53.924849
-

As with Laplacian pyramids, you can specify sub-levels and subbands to be included in the reconstruction. For example:

clf
-showIm(reconWpyr(pyr,pind,'qmf9','reflect1',[1:wpyrHt(pind)],[1]));  %Horizontal only
-
- -
-showIm(reconWpyr(pyr,pind,'qmf9','reflect1',[2,3])); %two middle scales
-
- -

PERFECT RECONSTRUCTION: HAAR AND DEBAUCHIES WAVELETS

-The symmetric QMF filters used above are not perfectly orthogonal. In fact, it's impossible to construct a symmetric filter of size greater than 2 that is perfectly orthogonal to shifted copies (shifted by multiples of 2) of itself. For example, consider a symmetric kernel of length 3. Shift by two and the right end of the original kernel is aligned with the left end of the shifted one. Thus, the inner product of these two will be the square of the end tap, which will be non-zero.
However, one can easily create wavelet filters of length 2 that will do the job. This is the oldest known wavelet, known as the "Haar". The two kernels are [1,1]/sqrt(2) and [1,-1]/sqrt(2). These are trivially seen to be orthogonal to each other, and shifts by multiples of two are also trivially orthogonal. The projection functions of the Haar transform are in the rows of the following matrix, constructed by applying the transform to impulse input signals, for all possible impulse locations:

haarLo = namedFilter('haar')
-haarHi = modulateFlip(haarLo)
-subplot(2,1,1); lplot(haarLo); axis([0 3 -1 1]); title('lowpass');
-subplot(2,1,2); lplot(haarHi); axis([0 3 -1 1]); title('highpass');
-
- -
-haarLo =
-
-    0.7071
-    0.7071
-
-
-haarHi =
-
-   -0.7071
-    0.7071
-
-
-
-
-M = [corrDn(eye(32), haarLo, 'reflect1', [2 1], [2 1]); ...
-    corrDn(eye(32), haarHi, 'reflect1', [2 1], [2 1])];
-clf; showIm(M)
-
-
-ans =
-
-   -0.7071    0.7071
-
-
-
- -
-showIm(M*M') %identity!
-
-ans =
-
-         0    1.0000
-
-
- -
As before, the filters are power-complementary (although the frequency isolation is rather poor, and thus the subbands will be heavily aliased):

-
plot(pi*[-32:31]/32,abs(fft(haarLo,64)).^2,'--',...
-     pi*[-32:31]/32,abs(fft(haarHi,64)).^2,'-');
-
- -
-sig = mkFract([1,64],0.5);
-[pyr,pind] = buildWpyr(sig,4,'haar','reflect1');
-showWpyr(pyr,pind);
-

check perfect reconstruction:

res = reconWpyr(pyr,pind, 'haar', 'reflect1');
-imStats(sig,res)
-
Difference statistics:
-  Range: [-2.775558e-16, 3.552714e-15]
-  Mean: 0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 300.614315
-

If you want perfect reconstruction, but don't like the Haar transform, there's another option: drop the symmetry requirement. Ingrid Daubechies developed one of the earliest sets of such perfect-reconstruction wavelets. The simplest of these is of length 4:

daub_lo = namedFilter('daub2');
-daub_hi = modulateFlip(daub_lo);
-

The daub_lo filter is constructed to be orthogonal to 2shifted copy of itself. For example:

-
[daub_lo;0;0]'*[0;0;daub_lo]
-
-
-ans =
-
-   2.9092e-13
-
-
-
-
-M = [corrDn(eye(32), daub_lo, 'circular', [2 1], [2 1]); ...
-    corrDn(eye(32), daub_hi, 'circular', [2 1], [2 1])];
-clf; showIm(M)
-
-
-ans =
-
-   -0.4830    0.8365
-
-
-
- -
-showIm(M*M') % identity!
-
-ans =
-
-         0    1.0000
-
-
- -
Again, they're power complementary:

plot(pi*[-32:31]/32,abs(fft(daub_lo,64)).^2,'--',...
-     pi*[-32:31]/32,abs(fft(daub_hi,64)).^2,'-');
-

The sum of the power spectra is again flat

plot(pi*[-32:31]/32,...
-    fftshift(abs(fft(daub_lo,64)).^2)+fftshift(abs(fft(daub_hi,64)).^2));
-

Make a pyramid using the same code as before (except that we can't use reflected boundaries with asymmetric filters):

[pyr,pind] = buildWpyr(sig, maxPyrHt(size(sig),size(daub_lo)), daub_lo, 'circular');
-showWpyr(pyr,pind,'indep1');
-
-res = reconWpyr(pyr,pind, daub_lo,'circular');
-imStats(sig,res);
-
-
-
Difference statistics:
-  Range: [-1.573097e-11, -2.440159e-12]
-  Mean: -0.000000,  Stdev (rmse): 0.000000,  SNR (dB): 228.416414
-
-

ALIASING IN WAVELET TRANSFORMS

-All of these orthonormal pyramid/wavelet transforms have a lot of aliasing in the subbands. You can see that in the frequency response plots since the frequency response of each filter covers well more than half the frequency domain. The aliasing can have serious consequences...
-Get one of the basis functions of the 2D Daubechies wavelet transform:

[pyr,pind] = buildWpyr(zeros(1,64),4,daub_lo,'circular');
-lev = 3;
-pyr(1+sum(pind(1:lev-1,2))+pind(lev,2)/2,1) = 1;
-sig = reconWpyr(pyr,pind, daub_lo,'circular');
-clf; lplot(sig)
-

Since the basis functions are orthonormal, building a pyramid using this input will yield a single non-zero coefficient.

[pyr,pind] = buildWpyr(sig, 4, daub_lo, 'circular');
-figure(1);
-nbands = size(pind,1)
-for b=1:nbands
-  subplot(nbands,1,b); lplot(pyrBand(pyr,pind,b));
-  axis([1 size(pyrBand(pyr,pind,b),2) -0.3 1.3]);
-end
-
-nbands =
-
-     5
-
-

Now shift the input by one sample and re-build the pyramid.

shifted_sig = [0,sig(1:size(sig,2)-1)];
-[spyr,spind] = buildWpyr(shifted_sig, 4, daub_lo, 'circular');
-

Plot each band of the unshifted and shifted decomposition

nextFig(2);
-nbands = size(spind,1)
-for b=1:nbands
-  subplot(nbands,1,b); lplot(pyrBand(spyr,spind,b));
-  axis([1 size(pyrBand(spyr,spind,b),2) -0.3 1.3]);
-end
-nextFig(2,-1);
-
-nbands =
-
-     5
-
-
-
In the third band, we expected the coefficients to move around because the signal was shifted. But notice that in the original signal decomposition, the other bands were filled with zeros. After the shift, they have significant content. Although these subbands are supposed to represent information at different scales, their content also depends on the relative POSITION of the input signal.
This problem is not unique to the Daubechies transform. The same is true for the QMF transform. Try it... In fact, the same kind of problem occurs for almost any orthogonal pyramid transform (the only exception is the limiting case in which the filter is a sinc function).
Orthogonal pyramid transforms are not shift-invariant. Although orthogonality may be an important property for some applications (e.g., data compression), orthogonal pyramid transforms are generally not so good for image analysis.
The overcompleteness of the Laplacian pyramid turns out to be a good thing in the end. By using an overcomplete representation (and by choosing the filters properly to avoid aliasing as much as possible), you end up with a representation that is useful for image analysis.

-

The "STEERABLE PYRAMID"

-The steerable pyramid is a multi-scale representation that istranslation-invariant, but that also includes representation of orientation. Furthermore, the representation of orientation is designed to be rotation-invariant. The basis/projection functions are oriented (steerable) filters, localized in space and frequency. It is overcomplete to avoid aliasing. And it is "self-inverting" (like the QMF/Wavelet transform): the projection functions and basis functions are identical. The mathematical phrase for a transform obeying this property is "tight frame".
-The system diagram for the steerable pyramid (described in the reference given below) is as follows:
-
IM ---> fhi0 -----------------> H0 ---------------- fhi0 ---> RESULT
-     |                                                     |
-     |                                                     |
-     |-> flo0 ---> fl1/down2 --> L1 --> up2/fl1 ---> flo0 -|
-               |                                 |
-               |----> fb0 -----> B0 ----> fb0 ---|
-               |                                 |
-               |----> fb1 -----> B1 ----> fb1 ---|
-               .                                 .
-               .                                 .
-               |----> fbK -----> BK ----> fbK ---|
-
The filters {fhi0,flo0} are used to initially split the image into a highpass residual band H0 and a lowpass subband. This lowpass band is then split into a low(er)pass band L1 and K+1 oriented subbands {B0,B1,...,BK}. The representatation is substantially overcomplete. The pyramid is built by recursively splitting the lowpass band (L1) using the inner portion of the diagram (i.e., using the filters {fl1,fb0,fb1,...,fbK}). The resulting transform is overcomplete by a factor of 4k/3.
-The scale tuning of the filters is constrained by the recursive system diagram. The orientation tuning is constrained by requiring the property of steerability. A set of filters form a steerable basis if they 1) are rotated copies of each other, and 2) a copy of the filter at any orientation may be computed as a linear combination of the basis filters. The simplest examples of steerable filters is a set of N+1 Nth-order directional derivatives.
-Choose a filter set (options are 'sp0Filters', 'sp1Filters', 'sp3Filters', 'sp5Filters'):

filts = 'sp3Filters';
-[lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filts);
-fsz = round(sqrt(size(bfilts,1))); fsz =  [fsz fsz];
-nfilts = size(bfilts,2);
-nrows = floor(sqrt(nfilts));
-

Look at the oriented bandpass filters:

figure
-for f = 1:nfilts
-  subplot(nrows,ceil(nfilts/nrows),f);
-  showIm(conv2(reshape(bfilts(:,f),fsz),lo0filt));
-end
-

Try "steering" to a new orientation (new_ori in degrees):

new_ori = 360*rand(1)
-clf; showIm(conv2(reshape(steer(bfilts, new_ori*pi/180 ), fsz), lo0filt));
-
-new_ori =
-
-  204.4158
-
-

Look at Fourier transform magnitudes:

lo0 = fftshift(abs(fft2(lo0filt,64,64)));
-fsum = zeros(size(lo0));
-figure
-for f = 1:size(bfilts,2)
-  subplot(nrows,ceil(nfilts/nrows),f);
-  flt = reshape(bfilts(:,f),fsz);
-  freq = lo0 .* fftshift(abs(fft2(flt,64,64)));
-  fsum = fsum + freq.^2;
-  showIm(freq);
-end
-

The filters sum to a smooth annular ring:

clf; showIm(fsum);
-

build a Steerable pyramid:

[pyr,pind] = buildSpyr(im, 4-imSubSample, filts);
-

Look at first (vertical) bands, different scales:

for s = 1:min(4,spyrHt(pind))
-  band = spyrBand(pyr,pind,s,1);
-  subplot(2,2,s); showIm(band);
-end
-

look at all orientation bands at one level (scale):

for b = 1:spyrNumBands(pind)
-  band = spyrBand(pyr,pind,1,b);
-  subplot(nrows,ceil(nfilts/nrows),b);
-  showIm(band);
-end
-

-
To access the high-pass and low-pass bands:

-
low = pyrLow(pyr,pind);
-showIm(low);
-
-
-
-high = spyrHigh(pyr,pind);
-showIm(high);
-
- -
Display the whole pyramid (except for the highpass residual band), with images shown at proper relative sizes:

showSpyr(pyr,pind);
-

Spin a level of the pyramid, interpolating (steering to) intermediate orienations:

-
[lev,lind] = spyrLev(pyr,pind,2);
-lev2 = reshape(lev,prod(lind(1,:)),size(bfilts,2));
-figure(1); subplot(1,1,1); showIm(spyrBand(pyr,pind,2,1));
-M = moviein(16);
-for frame = 1:16
-  steered_im = steer(lev2, 2*pi*(frame-1)/16, harmonics, steermtx);
-  showIm(reshape(steered_im, lind(1,:)),'auto2');
-  M(:,frame) = getframe;
-end
-
- -
Reconstruct. Note that the filters are not perfect, although they are good enough for most applications.

res = reconSpyr(pyr, pind, filts);
-showIm(im + i * res);
-imStats(im,res);
-
-
-Difference statistics:
-  Range: [-8.829810e+01, 1.084642e+02]
-  Mean: -0.611088,  Stdev (rmse): 13.451002,  SNR (dB): 8.384218
-
- -
As with previous pyramids, you can select subsets of the levels and orientation bands to be included in the reconstruction.
For example: All levels (including highpass and lowpass residuals), one orientation:

-
clf; showIm(reconSpyr(pyr,pind,filts,'reflect1','all', [1]));
-
- -
Without the highpass and lowpass:

-
clf; showIm(reconSpyr(pyr,pind,filts,'reflect1',[1:spyrHt(pind)], [1]));
-
- -
We also provide an implementation of the Steerable pyramid in the Frequency domain. The advantages are perfect-reconstruction (within floating-point error), and any number of orientation bands. The disadvantages are that it is typically slower, and the boundary handling is always circular.

[pyr,pind] = buildSFpyr(im,4,4); % 4 levels, 5 orientation bands
-showSpyr(pyr,pind);
-res = reconSFpyr(pyr,pind);
-imStats(im,res);  % nearly perfect
-
-
-Difference statistics:
-  Range: [-9.705222e-04, 1.297531e-03]
-  Mean: -0.000000,  Stdev (rmse): 0.000256,  SNR (dB): 102.810403
-
-
-

-The steerable pyramid transform given above is described in:
-E P Simoncelli and W T Freeman.
-The Steerable Pyramid: A Flexible Architecture for Multi-Scale -Derivative Computation.
-IEEE Second Int'l Conf on Image Processing. -Washington DC, October 1995.
-Online access:
-Abstract
-Full (PDF)
- - -
- - - diff --git a/evaluation/utils/matlabPyrTools/TUTORIALS/pyramids.m b/evaluation/utils/matlabPyrTools/TUTORIALS/pyramids.m deleted file mode 100755 index 2123c69..0000000 --- a/evaluation/utils/matlabPyrTools/TUTORIALS/pyramids.m +++ /dev/null @@ -1,903 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% IMAGE PYRAMID TUTORIAL -%%% -%%% A brief introduction to multi-scale pyramid decompositions for image -%%% processing. You should go through this, reading the comments, and -%%% executing the corresponding MatLab instructions. This file assumes -%%% a basic familiarity with matrix algebra, with linear systems and Fourier -%%% theory, and with MatLab. If you don't understand a particular -%%% function call, execute "help " to see documentation. -%%% -%%% EPS, 6/96. -%%% Based on the original OBVIUS tutorial. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%% Determine a subsampling factor for images, based on machine speed: -oim = pgmRead('einstein.pgm'); -tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc; -imSubSample = min(max(floor(log2(time)/2+3),0),2); -im = blurDn(oim, imSubSample,'qmf9'); -clear oim; -clf; showIm(im, 'auto2', 'auto', 'im'); - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% LAPLACIAN PYRAMIDS: - -%% Images may be decomposed into information at different scales. -%% Blurring eliminates the fine scales (detail): - -binom5 = binomialFilter(5); -lo_filt = binom5*binom5'; -blurred = rconv2(im,lo_filt); -subplot(1,2,1); showIm(im, 'auto2', 'auto', 'im'); -subplot(1,2,2); showIm(blurred, 'auto2', 'auto', 'blurred'); - -%% Subtracting the blurred image from the original leaves ONLY the -%% fine scale detail: -fine0 = im - blurred; -subplot(1,2,1); showIm(fine0, 'auto2', 'auto', 'fine0'); - -%% The blurred and fine images contain all the information found in -%% the original image. Trivially, adding the blurred image to the -%% fine scale detail will reconstruct the original. We can compare -%% the original image to the sum of blurred and fine using the -%% "imStats" function, which reports on the statistics of the -%% difference between it's arguments: -imStats(im, blurred+fine0); - -%% Since the filter is a lowpass filter, we might want to subsample -%% the blurred image. This may cause some aliasing (depends on the -%% filter), but the decomposition structure given above will still be -%% possible. The corrDn function correlates (same as convolution, but -%% flipped filter) and downsamples in a single operation (for -%% efficiency). The string 'reflect1' tells the function to handle -%% boundaries by reflecting the image about the edge pixels. Notice -%% that the blurred1 image is half the size (in each dimension) of the -%% original image. -lo_filt = 2*binom5*binom5'; %construct a separable 2D filter -blurred1 = corrDn(im,lo_filt,'reflect1',[2 2]); -subplot(1,2,2); showIm(blurred1,'auto2','auto','blurred1'); - -%% Now, to extract fine scale detail, we must interpolate the image -%% back up to full size before subtracting it from the original. The -%% upConv function does upsampling (padding with zeros between -%% samples) followed by convolution. This can be done using the -%% lowpass filter that was applied before subsampling or it can be -%% done with a different filter. -fine1 = im - upConv(blurred1,lo_filt,'reflect1',[2 2],[1 1],size(im)); -subplot(1,2,1); showIm(fine1,'auto2','auto','fine1'); - -%% We now have a technique that takes an image, computes two new -%% images (blurred1 and fine1) containing the coarse scale information -%% and the fine scale information. We can also (trivially) -%% reconstruct the original from these two (even if the subsampling of -%% the blurred1 image caused aliasing): - -recon = fine1 + upConv(blurred1,lo_filt,'reflect1',[2 2],[1 1],size(im)); -imStats(im, recon); - -%% Thus, we have described an INVERTIBLE linear transform that maps an -%% input image to the two images blurred1 and fine1. The inverse -%% transformation maps blurred1 and fine1 to the result. This is -%% depicted graphically with a system diagram: -%% -%% IM --> blur/down2 ---------> BLURRED1 --> up2/blur --> add --> RECON -%% | | ^ -%% | | | -%% | V | -%% | up2/blur | -%% | | | -%% | | | -%% | V | -%% --------------> subtract --> FINE1 ------------------- -%% -%% Note that the number of samples in the representation (i.e., total -%% samples in BLURRED1 and FINE1) is 1.5 times the number of samples -%% in the original IM. Thus, this representation is OVERCOMPLETE. - -%% Often, we will want further subdivisions of scale. We can -%% decompose the (coarse-scale) BLURRED1 image into medium coarse and -%% very coarse images by applying the same splitting technique: -blurred2 = corrDn(blurred1,lo_filt,'reflect1',[2 2]); -showIm(blurred2) - -fine2 = blurred1 - upConv(blurred2,lo_filt,'reflect1',[2 2],[1 1],size(blurred1)); -showIm(fine2) - -%% Since blurred2 and fine2 can be used to reconstruct blurred1, and -%% blurred1 and fine1 can be used to reconstruct the original image, -%% the set of THREE images (also known as "subbands") {blurred2, -%% fine2, fine1} constitute a complete representation of the original -%% image. Note that the three subbands are displayed at the same size, -%% but they are actually three different sizes. - -subplot(1,3,1); showIm(fine1,'auto2',2^(imSubSample-1),'fine1'); -subplot(1,3,2); showIm(fine2,'auto2',2^(imSubSample),'fine2'); -subplot(1,3,3); showIm(blurred2,'auto2',2^(imSubSample+1),'blurred2'); - -%% It is useful to consider exactly what information is stored in each -%% of the pyramid subbands. The reconstruction process involves -%% recursively interpolating these images and then adding them to the -%% image at the next finer scale. To see the contribution of ONE of -%% the representation images (say blurred2) to the reconstruction, we -%% imagine filling all the other subbands with zeros and then -%% following our reconstruction procedure. For the blurred2 subband, -%% this is equivalent to simply calling upConv twice: -blurred2_full = upConv(upConv(blurred2,lo_filt,'reflect1',[2 2],[1 1],size(blurred1)),... - lo_filt,'reflect1',[2 2],[1 1],size(im)); -subplot(1,3,3); showIm(blurred2_full,'auto2',2^(imSubSample-1),'blurred2-full'); - -%% For the fine2 subband, this is equivalent to calling upConv once: -fine2_full = upConv(fine2,lo_filt,'reflect1',[2 2],[1 1],size(im)); -subplot(1,3,2); showIm(fine2_full,'auto2',2^(imSubSample-1),'fine2-full'); - -%% If we did everything correctly, we should be able to add together -%% these three full-size images to reconstruct the original image: -recon = blurred2_full + fine2_full + fine1; -imStats(im, recon) - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% FUNCTIONS for CONSTRUCTING/MANIPULATING LAPLACIAN PYRAMIDS - -%% We can continue this process, recursively splitting off finer and -%% finer details from the blurred image (like peeling off the outer -%% layers of an onion). The resulting data structure is known as a -%% "Laplacian Pyramid". To make things easier, we have written a -%% MatLab function called buildLpyr to construct this object. The -%% function returns two items: a long vector containing the subbands -%% of the pyramid, and an index matrix that is used to access these -%% subbands. The display routine showLpyr shows all the subbands of the -%% pyramid, at the their correct relative sizes. It should now be -%% clearer why these data structures are called "pyramids". -[pyr,pind] = buildLpyr(im,5-imSubSample); -showLpyr(pyr,pind); - -%% There are also "accessor" functions for pulling out a single subband: -showIm(pyrBand(pyr,pind,2)); - -%% The reconLpyr function allows you to reconstruct from a laplacian pyramid. -%% The third (optional) arg allows you to select any subset of pyramid bands -%% (default is to use ALL of them). -clf; showIm(reconLpyr(pyr,pind,[1 3]),'auto2','auto','bands 1 and 3 only'); - -fullres = reconLpyr(pyr,pind); -showIm(fullres,'auto2','auto','Full reconstruction'); -imStats(im,fullres); - -%% buildLpyr uses 5-tap filters by default for building Laplacian -%% pyramids. You can specify other filters: -namedFilter('binom3') -[pyr3,pind3] = buildLpyr(im,5-imSubSample,'binom3'); -showLpyr(pyr3,pind3); -fullres3 = reconLpyr(pyr3,pind3,'all','binom3'); -imStats(im,fullres3); - -%% Here we build a "Laplacian" pyramid using random filters. filt1 is -%% used with the downsampling operations and filt2 is used with the -%% upsampling operations. We normalize the filters for display -%% purposes. Of course, these filters are (almost certainly) not very -%% "Gaussian", and the subbands of such a pyramid will be garbage! -%% Nevertheless, it is a simple property of the Laplacian pyramid that -%% we can use ANY filters and we will still be able to reconstruct -%% perfectly. - -filt1 = rand(1,5); filt1 = sqrt(2)*filt1/sum(filt1) -filt2 = rand(1,3); filt2 = sqrt(2)*filt2/sum(filt2) -[pyrr,pindr] = buildLpyr(im,5-imSubSample,filt1,filt2); -showLpyr(pyrr,pindr); -fullresr = reconLpyr(pyrr,pindr,'all',filt2); -imStats(im,fullresr); - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% ALIASING in the Gaussian and Laplacian pyramids: - -%% Unless one is careful, the subsampling operations will introduce aliasing -%% artifacts in these pyramid transforms. This is true even though the -%% Laplacian pyramid can be used to reconstruct the original image perfectly. -%% When reconstructing, the pyramid is designed in such a way that these -%% aliasing artifacts cancel out. So it's not a problem if the only thing we -%% want to do is reconstruct. However, it can be a serious problem if we -%% intend to process each of the subbands independently. - -%% One way to see the consequences of the aliasing artifacts is by -%% examining variations that occur when the input is shifted. We -%% choose an image and shift it by some number of pixels. Then blur -%% (filter-downsample-upsample-filter) the original image and blur the -%% shifted image. If there's no aliasing, then the blur and shift -%% operations should commute (i.e., -%% shift-filter-downsample-upsample-filter is the same as -%% filter-downsample-upsample-filter-shift). Try this for 2 different -%% filters (by replacing 'binom3' with 'binom5' or 'binom7' below), -%% and you'll see that the aliasing is much worse for the 3 tap -%% filter. - -sig = 100*randn([1 16]); -sh = [0 7]; %shift amount -lev = 2; % level of pyramid to look at -flt = 'binom3'; %filter to use: - -shiftIm = shift(sig,sh); -[pyr,pind] = buildLpyr(shiftIm, lev, flt, flt, 'circular'); -shiftBlur = reconLpyr(pyr, pind, lev, flt, 'circular'); - -[pyr,pind] = buildLpyr(sig, lev, flt, flt, 'circular'); -res = reconLpyr(pyr, pind, lev, flt, 'circular'); -blurShift = shift(res,sh); - -subplot(2,1,1); r = showIm(shiftBlur,'auto2','auto','shiftBlur'); -subplot(2,1,2); showIm(blurShift,r,'auto','blurShift'); -imStats(blurShift,shiftBlur); - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% PROJECTION and BASIS functions: - -%% An invertible, linear transform can be characterized in terms -%% of a set of PROJECTION and BASIS functions. In matlab matrix -%% notation: -% -%% c = P' * x -%% x = B * c -% -%% where x is an input, c are the transform coefficients, P and B -%% are matrices. The columns of P are the projection functions (the -%% input is projected onto the the columns of P to get each successive -%% transform coefficient). The columns of B are the basis -%% functions (x is a linear combination of the columns of B). - -%% Since the Laplacian pyramid is a linear transform, we can ask: what -%% are its BASIS functions? We consider these in one dimension for -%% simplicity. The BASIS function corresponding to a given -%% coefficient tells us how much that coefficient contributes to each -%% pixel in the reconstructed image. We can construct a single basis -%% function by setting one sample of one subband equal to 1.0 (and all -%% others to zero) and reconstructing. To build the entire matrix, we -%% have to do this for every sample of every subband: -sz = min(round(48/(sqrt(2)^imSubSample)),36); -sig = zeros(sz,1); -[pyr,pind] = buildLpyr(sig); -basis = zeros(sz,size(pyr,1)); -for n=1:size(pyr,1) - pyr = zeros(size(pyr)); - pyr(n) = 1; - basis(:,n) = reconLpyr(pyr,pind); -end -clf; showIm(basis) - -%% The columns of the basis matrix are the basis functions. The -%% matrix is short and fat, corresponding to the fact that the -%% representation is OVERCOMPLETE. Below, we plot the middle one from -%% each subband, starting with the finest scale. Note that all of -%% these basis functions are lowpass (Gaussian-like) functions. -locations = round(sz * (2 - 3./2.^[1:max(4,size(pind,1))]))+1; -for lev=1:size(locations,2) - subplot(2,2,lev); - showIm(basis(:,locations(lev))); - axis([0 sz 0 1.1]); -end - -%% Now, we'd also like see the inverse (we'll them PROJECTION) -%% functions. We need to ask how much of each sample of the input -%% image contributes to a given pyramid coefficient. Thus, the matrix -%% is constructed by building pyramids on the set of images with -%% impulses at each possible location. The rows of this matrix are -%% the projection functions. -projection = zeros(size(pyr,1),sz); -for pos=1:sz - [pyr,pind] = buildLpyr(mkImpulse([1 sz], [1 pos])); - projection(:,pos) = pyr; -end -clf; showIm(projection); - -%% Building a pyramid corresponds to multiplication by the projection -%% matrix. Reconstructing from this pyramid corresponds to -%% multiplication by the basis matrix. Thus, the product of the two -%% matrices (in this order) should be the identity matrix: -showIm(basis*projection); - -%% We can plot a few example projection functions at different scales. -%% Note that all of the projection functions are bandpass functions, -%% except for the coarsest subband which is lowpass. -for lev=1:size(locations,2) - subplot(2,2,lev); - showIm(projection(locations(lev),:)); - axis([0 sz -0.3 0.8]); -end - -%% Now consider the frequency response of these functions, plotted over the -%% range [-pi,pi]: -for lev=1:size(locations,2) - subplot(2,2,lev); - proj = projection(locations(lev),:); - plot(pi*[-32:31]/32,fftshift(abs(fft(proj',64)))); - axis([-pi pi -0.1 3]); -end - -%% The first projection function is highpass, and the second is bandpass. Both -%% of these look something like the Laplacian (2nd derivative) of a Gaussian. -%% The last is lowpass, as are the basis functions. Thus, the basic operation -%% used to create each level of the pyramid involves a simple highpass/lowpass -%% split. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% QMF/WAVELET PYRAMIDS. - -%% Two things about Laplacian pyramids are a bit unsatisfactory. -%% First, there are more pixels (coefficients) in the representation -%% than in the original image. Specifically, the 1-dimensional -%% transform is overcomplete by a factor of 4/3, and the 2-dimensional -%% transform is overcomplete by a factor of 2. Secondly, the -%% "bandpass" images (fineN) do not segregate information according to -%% orientation. - -%% There are other varieties of pyramid. One type that arose in the -%% speech coding community is based on a particular pairs of filters -%% known as a "Quadrature Mirror Filters" or QMFs. These are closely -%% related to Wavelets (essentially, they are approximate wavelet -%% filters). - -%% Recall that the Laplacian pyramid is formed by simple hi/low -%% splitting at each level. The lowpass band is subsampled by a -%% factor of 2, but the highpass band is NOT subsampled. In the QMF -%% pyramid, we apply two filters (hi- and lo- pass) and subsample BOTH -%% by a factor of 2, thus eliminating the excess coefficients of the -%% Laplacian pyramid. - -%% The two filters must have a specific relationship to each -%% other. In particular, let n be an index for the filter samples. -%% The highpass filter may be constructed from the lowpass filter by -%% (1) modulating (multiplying) by (-1)^n (equivalent to shifting by -%% pi in the Fourier domain), (2) flipping (i.e., reversing the order -%% of the taps), (3) spatially shifting by one sample. Try to -%% convince yourself that the resulting filters will always be -%% orthogonal to each other (i.e., their inner products will be zero) -%% when shifted by any multiple of two. - -%% The function modulateFlip performs the first two of these operations. The -%% third (spatial shifting) step is built into the convolution code. -flo = namedFilter('qmf9')'; -fhi = modulateFlip(flo)'; -subplot(2,1,1); lplot(flo); axis([0 10 -0.5 1.0]); title('lowpass'); -subplot(2,1,2); lplot(fhi); axis([0 10 -0.5 1.0]); title('highpass'); - -%% In the Fourier domain, these filters are (approximately) -%% "power-complementary": the sum of their squared power spectra is -%% (approximately) a constant. But note that neither is a perfect -%% bandlimiter (i.e., a sinc function), and thus subsampling by a -%% factor of 2 will cause aliasing in each of the subbands. See below -%% for a discussion of the effect of this aliasing. - -%% Plot the two frequency responses: -freq = pi*[-32:31]/32; -subplot(2,1,1); -plot(freq,fftshift(abs(fft(flo,64))),'--',freq,fftshift(abs(fft(fhi,64))),'-'); -axis([-pi pi 0 1.5]); title('FFT magnitudes'); -subplot(2,1,2); -plot(freq,fftshift(abs(fft(flo,64)).^2)+fftshift(abs(fft(fhi,64)).^2)); -axis([-pi pi 0 2.2]); title('Sum of squared magnitudes'); - -%% We can split an input signal into two bands as follows: -sig = mkFract([1,64],1.6); -subplot(2,1,1); showIm(sig,'auto1','auto','sig'); -lo1 = corrDn(sig,flo,'reflect1',[1 2],[1 1]); -hi1 = corrDn(sig,fhi,'reflect1',[1 2],[1 2]); -subplot(2,1,2); -showIm(lo1,'auto1','auto','low and high bands'); hold on; plot(hi1,'--r'); hold off; - -%% Notice that the two subbands are half the size of the original -%% image, due to the subsampling by a factor of 2. One subtle point: -%% the highpass and lowpass bands are subsampled on different -%% lattices: the lowpass band retains the odd-numbered samples and the -%% highpass band retains the even-numbered samples. This was the -%% 1-sample shift relating the high and lowpass kernels (mentioned -%% above). We've used the 'reflect1' to handle boundaries, which -%% works properly for symmetric odd-length QMFs. - -%% We can reconstruct the original image by interpolating these two subbands -%% USING THE SAME FILTERS: -reconlo = upConv(lo1,flo,'reflect1',[1 2]); -reconhi = upConv(hi1,fhi,'reflect1',[1 2],[1 2]); -subplot(2,1,2); showIm(reconlo+reconhi,'auto1','auto','reconstructed'); -imStats(sig,reconlo+reconhi); - -%% We have described an INVERTIBLE linear transform that maps an input -%% image to the two images lo1 and hi1. The inverse transformation -%% maps these two images to the result. This is depicted graphically -%% with a system diagram: -%% -%% IM ---> flo/down2 --> LO1 --> up2/flo --> add --> RECON -%% | ^ -%% | | -%% | | -%% -> fhi/down2 --> HI1 --> up2/fhi ----- -%% -%% Note that the number of samples in the representation (i.e., total -%% samples in LO1 and HI1) is equal to the number of samples in the -%% original IM. Thus, this representation is exactly COMPLETE, or -%% "critically sampled". - -%% So we've fixed one of the problems that we had with Laplacian -%% pyramid. But the system diagram above places strong constraints on -%% the filters. In particular, for these filters the reconstruction -%% is no longer perfect. Turns out there are NO -%% perfect-reconstruction symmetric filters that are -%% power-complementary, except for the trivial case [1] and the -%% nearly-trivial case [1 1]/sqrt(2). - -%% Let's consider the projection functions of this 2-band splitting -%% operation. We can construct these by applying the transform to -%% impulse input signals, for all possible impulse locations. The -%% rows of the following matrix are the projection functions for each -%% coefficient in the transform. -M = [corrDn(eye(32),flo','circular',[1 2]), ... - corrDn(eye(32),fhi','circular',[1 2],[1 2])]'; -clf; showIm(M,'auto1','auto','M'); - -%% The transform matrix is composed of two sub-matrices. The top half -%% contains the lowpass kernel, shifted by increments of 2 samples. -%% The bottom half contains the highpass. Now we compute the inverse -%% of this matrix: -M_inv = inv(M); -showIm(M_inv,'auto1','auto','M_inv'); - -%% The inverse is (very close to) the transpose of the original -%% matrix! In other words, the transform is orthonormal. -imStats(M_inv',M); - -%% This also points out a nice relationship between the corrDn and -%% upConv functions, and the matrix representation. corrDn is -%% equivalent to multiplication by a matrix with copies of the filter -%% on the ROWS, translated in multiples of the downsampling factor. -%% upConv is equivalent to multiplication by a matrix with copies of -%% the filter on the COLUMNS, translated by the upsampling factor. - -%% As in the Laplacian pyramid, we can recursively apply this QMF -%% band-splitting operation to the lowpass band: -lo2 = corrDn(lo1,flo,'reflect1',[1 2]); -hi2 = corrDn(lo1,fhi,'reflect1',[1 2],[1 2]); - -%% The representation of the original signal is now comprised of the -%% three subbands {hi1, hi2, lo2} (we don't hold onto lo1, because it -%% can be reconstructed from lo2 and hi2). Note that hi1 is at 1/2 -%% resolution, and hi2 and lo2 are at 1/4 resolution: The total number -%% of samples in these three subbands is thus equal to the number of -%% samples in the original signal. -imnames=['hi1'; 'hi2'; 'lo2']; -for bnum=1:3 - band = eval(imnames(bnum,:)); - subplot(3,1,bnum); showIm(band); ylabel(imnames(bnum,:)); - axis([1 size(band,2) 1.1*min(lo2) 1.1*max(lo2)]); -end - -%% Reconstruction proceeds as with the Laplacian pyramid: combine lo2 and hi2 -%% to reconstruct lo1, which is then combined with hi1 to reconstruct the -%% original signal: -recon_lo1 = upConv(hi2,fhi,'reflect1',[1 2],[1 2]) + ... - upConv(lo2,flo,'reflect1',[1 2],[1 1]); -reconstructed = upConv(hi1,fhi,'reflect1',[1 2],[1 2]) + ... - upConv(recon_lo1,flo,'reflect1',[1 2],[1 1]); -imStats(sig,reconstructed); - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% FUNCTIONS for CONSTRUCTING/MANIPULATING QMF/Wavelet PYRAMIDS - -%% To make things easier, we have bundled these qmf operations and -%% data structures into an object in MATLAB. - -sig = mkFract([1 64], 1.5); -[pyr,pind] = buildWpyr(sig); -showWpyr(pyr,pind); - -nbands = size(pind,1); -for b = 1:nbands - subplot(nbands,1,b); lplot(pyrBand(pyr,pind,b)); -end - -res = reconWpyr(pyr,pind); -imStats(sig,res); - -%% Now for 2D, we use separable filters. There are 4 ways to apply the two -%% filters to the input image (followed by the relavent subsampling operation): -%% (1) lowpass in both x and y -%% (2) lowpass in x and highpass in y -%% (3) lowpass in y and highpass in x -%% (4) highpass in both x and y. -%% The pyramid is built by recursively subdividing the first of these bands -%% into four new subbands. - -%% First, we'll take a look at some of the basis functions. -sz = 40; -zim = zeros(sz); -flo = 'qmf9'; edges = 'reflect1'; -[pyr,pind] = buildWpyr(zim); - -% Put an impulse into the middle of each band: -for lev=1:size(pind,1) - mid = sum(prod(pind(1:lev-1,:)')); - mid = mid + floor(pind(lev,2)/2)*pind(lev,1) + floor(pind(lev,1)/2) + 1; - pyr(mid,1) = 1; -end - -% And take a look at the reconstruction of each band: -for lnum=1:wpyrHt(pind)+1 - for bnum=1:3 - subplot(wpyrHt(pind)+1,3,(wpyrHt(pind)+1-lnum)*3+bnum); - showIm(reconWpyr(pyr, pind, flo, edges, lnum, bnum),'auto1',2,0); - end -end - -%% Note that the first column contains horizontally oriented basis functions at -%% different scales. The second contains vertically oriented basis functions. -%% The third contains both diagonals (a checkerboard pattern). The bottom row -%% shows (3 identical images of) a lowpass basis function. - -%% Now look at the corresponding Fourier transform magnitudes (these -%% are plotted over the frequency range [-pi, pi] ): -nextFig(2,1); -freq = 2 * pi * [-sz/2:(sz/2-1)]/sz; -for lnum=1:wpyrHt(pind)+1 - for bnum=1:3 - subplot(wpyrHt(pind)+1,3,(wpyrHt(pind)+1-lnum)*3+bnum); - basisFn = reconWpyr(pyr, pind, flo, edges, lnum, bnum); - basisFmag = fftshift(abs(fft2(basisFn,sz,sz))); - imagesc(freq,freq,basisFmag); - axis('square'); axis('xy'); colormap('gray'); - end -end -nextFig(2,-1); - -%% The filters at a given scale sum to a squarish annular region: -sumSpectra = zeros(sz); -lnum = 2; -for bnum=1:3 - basisFn = reconWpyr(pyr, pind, flo, edges, lnum, bnum); - basisFmag = fftshift(abs(fft2(basisFn,sz,sz))); - sumSpectra = basisFmag.^2 + sumSpectra; -end -clf; imagesc(freq,freq,sumSpectra); axis('square'); axis('xy'); title('one scale'); - -%% Now decompose an image: -[pyr,pind] = buildWpyr(im); - -%% View all of the subbands (except lowpass), scaled to be the same size -%% (requires a big figure window): -nlevs = wpyrHt(pind); -for lnum=1:nlevs - for bnum=1:3 - subplot(nlevs,3,(lnum-1)*3+bnum); - showIm(wpyrBand(pyr,pind,lnum,bnum), 'auto2', 2^(lnum+imSubSample-2)); - end -end - -%% In addition to the bands shown above, there's a lowpass residual: -nextFig(2,1); -clf; showIm(pyrLow(pyr,pind)); -nextFig(2,-1); - -% Alternatively, display the pyramid with the subbands shown at their -% correct relative sizes: -clf; showWpyr(pyr, pind); - -%% The reconWpyr function can be used to reconstruct the entire pyramid: -reconstructed = reconWpyr(pyr,pind); -imStats(im,reconstructed); - -%% As with Laplacian pyramids, you can specify sub-levels and subbands -%% to be included in the reconstruction. For example: -clf -showIm(reconWpyr(pyr,pind,'qmf9','reflect1',[1:wpyrHt(pind)],[1])); %Horizontal only -showIm(reconWpyr(pyr,pind,'qmf9','reflect1',[2,3])); %two middle scales - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% PERFECT RECONSTRUCTION: HAAR AND DEBAUCHIES WAVELETS - -%% The symmetric QMF filters used above are not perfectly orthogonal. -%% In fact, it's impossible to construct a symmetric filter of size -%% greater than 2 that is perfectly orthogonal to shifted copies -%% (shifted by multiples of 2) of itself. For example, consider a -%% symmetric kernel of length 3. Shift by two and the right end of -%% the original kernel is aligned with the left end of the shifted -%% one. Thus, the inner product of these two will be the square of -%% the end tap, which will be non-zero. - -%% However, one can easily create wavelet filters of length 2 that -%% will do the job. This is the oldest known wavelet, known as the -%% "Haar". The two kernels are [1,1]/sqrt(2) and [1,-1]/sqrt(2). -%% These are trivially seen to be orthogonal to each other, and shifts -%% by multiples of two are also trivially orthogonal. The projection -%% functions of the Haar transform are in the rows of the following -%% matrix, constructed by applying the transform to impulse input -%% signals, for all possible impulse locations: - -haarLo = namedFilter('haar') -haarHi = modulateFlip(haarLo) -subplot(2,1,1); lplot(haarLo); axis([0 3 -1 1]); title('lowpass'); -subplot(2,1,2); lplot(haarHi); axis([0 3 -1 1]); title('highpass'); - -M = [corrDn(eye(32), haarLo, 'reflect1', [2 1], [2 1]); ... - corrDn(eye(32), haarHi, 'reflect1', [2 1], [2 1])]; -clf; showIm(M) -showIm(M*M') %identity! - -%% As before, the filters are power-complementary (although the -%% frequency isolation is rather poor, and thus the subbands will be -%% heavily aliased): -plot(pi*[-32:31]/32,abs(fft(haarLo,64)).^2,'--',... - pi*[-32:31]/32,abs(fft(haarHi,64)).^2,'-'); - -sig = mkFract([1,64],0.5); -[pyr,pind] = buildWpyr(sig,4,'haar','reflect1'); -showWpyr(pyr,pind); - -%% check perfect reconstruction: -res = reconWpyr(pyr,pind, 'haar', 'reflect1'); -imStats(sig,res) - -%% If you want perfect reconstruction, but don't like the Haar -%% transform, there's another option: drop the symmetry requirement. -%% Ingrid Daubechies developed one of the earliest sets of such -%% perfect-reconstruction wavelets. The simplest of these is of -%% length 4: - -daub_lo = namedFilter('daub2'); -daub_hi = modulateFlip(daub_lo); - -%% The daub_lo filter is constructed to be orthogonal to 2shifted -%% copy of itself. For example: -[daub_lo;0;0]'*[0;0;daub_lo] - -M = [corrDn(eye(32), daub_lo, 'circular', [2 1], [2 1]); ... - corrDn(eye(32), daub_hi, 'circular', [2 1], [2 1])]; -clf; showIm(M) -showIm(M*M') % identity! - -%% Again, they're power complementary: -plot(pi*[-32:31]/32,abs(fft(daub_lo,64)).^2,'--',... - pi*[-32:31]/32,abs(fft(daub_hi,64)).^2,'-'); - -%% The sum of the power spectra is again flat -plot(pi*[-32:31]/32,... - fftshift(abs(fft(daub_lo,64)).^2)+fftshift(abs(fft(daub_hi,64)).^2)); - -%% Make a pyramid using the same code as before (except that we can't -%% use reflected boundaries with asymmetric filters): -[pyr,pind] = buildWpyr(sig, maxPyrHt(size(sig),size(daub_lo)), daub_lo, 'circular'); -showWpyr(pyr,pind,'indep1'); - -res = reconWpyr(pyr,pind, daub_lo,'circular'); -imStats(sig,res); - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% ALIASING IN WAVELET TRANSFORMS - -%% All of these orthonormal pyramid/wavelet transforms have a lot -%% of aliasing in the subbands. You can see that in the frequency -%% response plots since the frequency response of each filter -%% covers well more than half the frequency domain. The aliasing -%% can have serious consequences... - -%% Get one of the basis functions of the 2D Daubechies wavelet transform: -[pyr,pind] = buildWpyr(zeros(1,64),4,daub_lo,'circular'); -lev = 3; -pyr(1+sum(pind(1:lev-1,2))+pind(lev,2)/2,1) = 1; -sig = reconWpyr(pyr,pind, daub_lo,'circular'); -clf; lplot(sig) - -%% Since the basis functions are orthonormal, building a pyramid using this -%% input will yield a single non-zero coefficient. -[pyr,pind] = buildWpyr(sig, 4, daub_lo, 'circular'); -figure(1); -nbands = size(pind,1) -for b=1:nbands - subplot(nbands,1,b); lplot(pyrBand(pyr,pind,b)); - axis([1 size(pyrBand(pyr,pind,b),2) -0.3 1.3]); -end - -%% Now shift the input by one sample and re-build the pyramid. -shifted_sig = [0,sig(1:size(sig,2)-1)]; -[spyr,spind] = buildWpyr(shifted_sig, 4, daub_lo, 'circular'); - -%% Plot each band of the unshifted and shifted decomposition -nextFig(2); -nbands = size(spind,1) -for b=1:nbands - subplot(nbands,1,b); lplot(pyrBand(spyr,spind,b)); - axis([1 size(pyrBand(spyr,spind,b),2) -0.3 1.3]); -end -nextFig(2,-1); - -%% In the third band, we expected the coefficients to move around -%% because the signal was shifted. But notice that in the original -%% signal decomposition, the other bands were filled with zeros. -%% After the shift, they have significant content. Although these -%% subbands are supposed to represent information at different scales, -%% their content also depends on the relative POSITION of the input -%% signal. - -%% This problem is not unique to the Daubechies transform. The same -%% is true for the QMF transform. Try it... In fact, the same kind -%% of problem occurs for almost any orthogonal pyramid transform (the -%% only exception is the limiting case in which the filter is a sinc -%% function). - -%% Orthogonal pyramid transforms are not shift-invariant. Although -%% orthogonality may be an important property for some applications -%% (e.g., data compression), orthogonal pyramid transforms are -%% generally not so good for image analysis. - -%% The overcompleteness of the Laplacian pyramid turns out to be a -%% good thing in the end. By using an overcomplete representation -%% (and by choosing the filters properly to avoid aliasing as much as -%% possible), you end up with a representation that is useful for -%% image analysis. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% The "STEERABLE PYRAMID" - -%% The steerable pyramid is a multi-scale representation that is -%% translation-invariant, but that also includes representation of -%% orientation. Furthermore, the representation of orientation is -%% designed to be rotation-invariant. The basis/projection functions -%% are oriented (steerable) filters, localized in space and frequency. -%% It is overcomplete to avoid aliasing. And it is "self-inverting" -%% (like the QMF/Wavelet transform): the projection functions and -%% basis functions are identical. The mathematical phrase for a -%% transform obeying this property is "tight frame". - -%% The system diagram for the steerable pyramid (described in the -%% reference given below) is as follows: -% -% IM ---> fhi0 -----------------> H0 ---------------- fhi0 ---> RESULT -% | | -% | | -% |-> flo0 ---> fl1/down2 --> L1 --> up2/fl1 ---> flo0 -| -% | | -% |----> fb0 -----> B0 ----> fb0 ---| -% | | -% |----> fb1 -----> B1 ----> fb1 ---| -% . . -% . . -% |----> fbK -----> BK ----> fbK ---| -% -%% The filters {fhi0,flo0} are used to initially split the image into -%% a highpass residual band H0 and a lowpass subband. This lowpass -%% band is then split into a low(er)pass band L1 and K+1 oriented -%% subbands {B0,B1,...,BK}. The representatation is substantially -%% overcomplete. The pyramid is built by recursively splitting the -%% lowpass band (L1) using the inner portion of the diagram (i.e., -%% using the filters {fl1,fb0,fb1,...,fbK}). The resulting transform is -%% overcomplete by a factor of 4k/3. - -%% The scale tuning of the filters is constrained by the recursive -%% system diagram. The orientation tuning is constrained by requiring -%% the property of steerability. A set of filters form a steerable -%% basis if they 1) are rotated copies of each other, and 2) a copy of -%% the filter at any orientation may be computed as a linear -%% combination of the basis filters. The simplest examples of -%% steerable filters is a set of N+1 Nth-order directional -%% derivatives. - -%% Choose a filter set (options are 'sp0Filters', 'sp1Filters', -%% 'sp3Filters', 'sp5Filters'): -filts = 'sp3Filters'; -[lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filts); -fsz = round(sqrt(size(bfilts,1))); fsz = [fsz fsz]; -nfilts = size(bfilts,2); -nrows = floor(sqrt(nfilts)); - -%% Look at the oriented bandpass filters: -for f = 1:nfilts - subplot(nrows,ceil(nfilts/nrows),f); - showIm(conv2(reshape(bfilts(:,f),fsz),lo0filt)); -end - -%% Try "steering" to a new orientation (new_ori in degrees): -new_ori = 360*rand(1) -clf; showIm(conv2(reshape(steer(bfilts, new_ori*pi/180 ), fsz), lo0filt)); - -%% Look at Fourier transform magnitudes: -lo0 = fftshift(abs(fft2(lo0filt,64,64))); -fsum = zeros(size(lo0)); -for f = 1:size(bfilts,2) - subplot(nrows,ceil(nfilts/nrows),f); - flt = reshape(bfilts(:,f),fsz); - freq = lo0 .* fftshift(abs(fft2(flt,64,64))); - fsum = fsum + freq.^2; - showIm(freq); -end - -%% The filters sum to a smooth annular ring: -clf; showIm(fsum); - -%% build a Steerable pyramid: -[pyr,pind] = buildSpyr(im, 4-imSubSample, filts); - -%% Look at first (vertical) bands, different scales: -for s = 1:min(4,spyrHt(pind)) - band = spyrBand(pyr,pind,s,1); - subplot(2,2,s); showIm(band); -end - -%% look at all orientation bands at one level (scale): -for b = 1:spyrNumBands(pind) - band = spyrBand(pyr,pind,1,b); - subplot(nrows,ceil(nfilts/nrows),b); - showIm(band); -end - -%% To access the high-pass and low-pass bands: -low = pyrLow(pyr,pind); -showIm(low); -high = spyrHigh(pyr,pind); -showIm(high); - -%% Display the whole pyramid (except for the highpass residual band), -%% with images shown at proper relative sizes: -showSpyr(pyr,pind); - -%% Spin a level of the pyramid, interpolating (steering to) -%% intermediate orienations: - -[lev,lind] = spyrLev(pyr,pind,2); -lev2 = reshape(lev,prod(lind(1,:)),size(bfilts,2)); -figure(1); subplot(1,1,1); showIm(spyrBand(pyr,pind,2,1)); -M = moviein(16); -for frame = 1:16 - steered_im = steer(lev2, 2*pi*(frame-1)/16, harmonics, steermtx); - showIm(reshape(steered_im, lind(1,:)),'auto2'); - M(:,frame) = getframe; -end - -%% Show the movie 3 times: -movie(M,3); - -%% Reconstruct. Note that the filters are not perfect, although they are good -%% enough for most applications. -res = reconSpyr(pyr, pind, filts); -showIm(im + i * res); -imStats(im,res); - -%% As with previous pyramids, you can select subsets of the levels -%% and orientation bands to be included in the reconstruction. For example: - -%% All levels (including highpass and lowpass residuals), one orientation: -clf; showIm(reconSpyr(pyr,pind,filts,'reflect1','all', [1])); - -%% Without the highpass and lowpass: -clf; showIm(reconSpyr(pyr,pind,filts,'reflect1',[1:spyrHt(pind)], [1])); - -%% We also provide an implementation of the Steerable pyramid in the -%% Frequency domain. The advantages are perfect-reconstruction -%% (within floating-point error), and any number of orientation -%% bands. The disadvantages are that it is typically slower, and the -%% boundary handling is always circular. - -[pyr,pind] = buildSFpyr(im,4,4); % 4 levels, 5 orientation bands -showSpyr(pyr,pind); -res = reconSFpyr(pyr,pind); -imStats(im,res); % nearly perfect - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% The steerable pyramid transform given above is described in: -% -% E P Simoncelli and W T Freeman. -% The Steerable Pyramid: A Flexible Architecture for Multi-Scale -% Derivative Computation. IEEE Second Int'l Conf on Image Processing. -% Washington DC, October 1995. -% -% Online access: -% Abstract: http://www.cis.upenn.edu/~eero/ABSTRACTS/simoncelli95b-abstract.html -% Full (PostScript): ftp://ftp.cis.upenn.edu/pub/eero/simoncelli95b.ps.Z -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%% Local Variables: -%% buffer-read-only: t -%% End: diff --git a/evaluation/utils/matlabPyrTools/binomialFilter.m b/evaluation/utils/matlabPyrTools/binomialFilter.m deleted file mode 100755 index e5670c7..0000000 --- a/evaluation/utils/matlabPyrTools/binomialFilter.m +++ /dev/null @@ -1,18 +0,0 @@ -% KERNEL = binomialFilter(size) -% -% Returns a vector of binomial coefficients of order (size-1) . - -% Eero Simoncelli, 2/97. - -function [kernel] = binomialFilter(sz) - -if (sz < 2) - error('size argument must be larger than 1'); -end - -kernel = [0.5 0.5]'; - -for n=1:sz-2 - kernel = conv([0.5 0.5]', kernel); -end - diff --git a/evaluation/utils/matlabPyrTools/blur.m b/evaluation/utils/matlabPyrTools/blur.m deleted file mode 100755 index fccb103..0000000 --- a/evaluation/utils/matlabPyrTools/blur.m +++ /dev/null @@ -1,67 +0,0 @@ -% RES = blur(IM, LEVELS, FILT) -% -% Blur an image, by filtering and downsampling LEVELS times -% (default=1), followed by upsampling and filtering LEVELS times. The -% blurring is done with filter kernel specified by FILT (default = -% 'binom5'), which can be a string (to be passed to namedFilter), a -% vector (applied separably as a 1D convolution kernel in X and Y), or -% a matrix (applied as a 2D convolution kernel). The downsampling is -% always by 2 in each direction. - -% Eero Simoncelli, 3/04. - -function res = blur(im, nlevs, filt) - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('nlevs') ~= 1) - nlevs = 1; -end - -if (exist('filt') ~= 1) - filt = 'binom5'; -end - -%------------------------------------------------------------ - -if isstr(filt) - filt = namedFilter(filt); -end - -filt = filt/sum(filt(:)); - -if nlevs > 0 - if (any(size(im)==1)) - if (~any(size(filt)==1)) - error('Cant apply 2D filter to 1D signal'); - end - if (size(im,2)==1) - filt = filt(:); - else - filt = filt(:)'; - end - - in = corrDn(im,filt,'reflect1',(size(im)~=1)+1); - out = blur(in, nlevs-1, filt); - res = upConv(out, filt, 'reflect1', (size(im)~=1)+1, [1 1], size(im)); - - elseif (any(size(filt)==1)) - filt = filt(:); - - in = corrDn(im,filt,'reflect1',[2 1]); - in = corrDn(in,filt','reflect1',[1 2]); - out = blur(in, nlevs-1, filt); - res = upConv(out, filt', 'reflect1', [1 2], [1 1], [size(out,1),size(im,2)]); - res = upConv(res, filt, 'reflect1', [2 1], [1 1], size(im)); - - else - - in = corrDn(im,filt,'reflect1',[2 2]); - out = blur(in, nlevs-1, filt); - res = upConv(out, filt, 'reflect1', [2 2], [1 1], size(im)); - end -else - res = im; -end - diff --git a/evaluation/utils/matlabPyrTools/blurDn.m b/evaluation/utils/matlabPyrTools/blurDn.m deleted file mode 100755 index 8120c04..0000000 --- a/evaluation/utils/matlabPyrTools/blurDn.m +++ /dev/null @@ -1,59 +0,0 @@ -% RES = blurDn(IM, LEVELS, FILT) -% -% Blur and downsample an image. The blurring is done with filter -% kernel specified by FILT (default = 'binom5'), which can be a string -% (to be passed to namedFilter), a vector (applied separably as a 1D -% convolution kernel in X and Y), or a matrix (applied as a 2D -% convolution kernel). The downsampling is always by 2 in each -% direction. -% -% The procedure is applied recursively LEVELS times (default=1). - -% Eero Simoncelli, 3/97. - -function res = blurDn(im, nlevs, filt) - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('nlevs') ~= 1) - nlevs = 1; -end - -if (exist('filt') ~= 1) - filt = 'binom5'; -end - -%------------------------------------------------------------ - -if isstr(filt) - filt = namedFilter(filt); -end - -filt = filt/sum(filt(:)); - -if nlevs > 1 - im = blurDn(im,nlevs-1,filt); -end - -if (nlevs >= 1) - if (any(size(im)==1)) - if (~any(size(filt)==1)) - error('Cant apply 2D filter to 1D signal'); - end - if (size(im,2)==1) - filt = filt(:); - else - filt = filt(:)'; - end - res = corrDn(im,filt,'reflect1',(size(im)~=1)+1); - elseif (any(size(filt)==1)) - filt = filt(:); - res = corrDn(im,filt,'reflect1',[2 1]); - res = corrDn(res,filt','reflect1',[1 2]); - else - res = corrDn(im,filt,'reflect1',[2 2]); - end -else - res = im; -end diff --git a/evaluation/utils/matlabPyrTools/buildGpyr.m b/evaluation/utils/matlabPyrTools/buildGpyr.m deleted file mode 100755 index 3f3d07b..0000000 --- a/evaluation/utils/matlabPyrTools/buildGpyr.m +++ /dev/null @@ -1,82 +0,0 @@ -% [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES) -% -% Construct a Gaussian pyramid on matrix IM. -% -% HEIGHT (optional) specifies the number of pyramid levels to build. Default -% is 1+maxPyrHt(size(IM),size(FILT)). -% You can also specify 'auto' to use this value. -% -% FILT (optional) can be a string naming a standard filter (see -% namedFilter), or a vector which will be used for (separable) -% convolution. Default = 'binom5'. EDGES specifies edge-handling, and -% defaults to 'reflect1' (see corrDn). -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. - -% Eero Simoncelli, 6/96. - -function [pyr,pind] = buildGpyr(im, ht, filt, edges) - -if (nargin < 1) - error('First argument (IM) is required'); -end - -im_sz = size(im); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('filt') ~= 1) - filt = 'binom5'; -end - -if isstr(filt) - filt = namedFilter(filt); -end - -if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) - error('FILT should be a 1D filter (i.e., a vector)'); -else - filt = filt(:); -end - -max_ht = 1 + maxPyrHt(im_sz, size(filt,1)); -if ( (exist('ht') ~= 1) | (ht == 'auto') ) - ht = max_ht; -else - if (ht > max_ht) - error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); - end -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end - -%------------------------------------------------------------ - -if (ht <= 1) - - pyr = im(:); - pind = im_sz; - -else - - if (im_sz(2) == 1) - lo2 = corrDn(im, filt, edges, [2 1], [1 1]); - elseif (im_sz(1) == 1) - lo2 = corrDn(im, filt', edges, [1 2], [1 1]); - else - lo = corrDn(im, filt', edges, [1 2], [1 1]); - lo2 = corrDn(lo, filt, edges, [2 1], [1 1]); - end - - [npyr,nind] = buildGpyr(lo2, ht-1, filt, edges); - - pyr = [im(:); npyr]; - pind = [im_sz; nind]; - -end - diff --git a/evaluation/utils/matlabPyrTools/buildLpyr.m b/evaluation/utils/matlabPyrTools/buildLpyr.m deleted file mode 100755 index facb0f3..0000000 --- a/evaluation/utils/matlabPyrTools/buildLpyr.m +++ /dev/null @@ -1,109 +0,0 @@ -% [PYR, INDICES] = buildLpyr(IM, HEIGHT, FILT1, FILT2, EDGES) -% -% Construct a Laplacian pyramid on matrix (or vector) IM. -% -% HEIGHT (optional) specifies the number of pyramid levels to build. Default -% is 1+maxPyrHt(size(IM),size(FILT)). You can also specify 'auto' to -% use this value. -% -% FILT1 (optional) can be a string naming a standard filter (see -% namedFilter), or a vector which will be used for (separable) -% convolution. Default = 'binom5'. FILT2 specifies the "expansion" -% filter (default = filt1). EDGES specifies edge-handling, and -% defaults to 'reflect1' (see corrDn). -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. - -% Eero Simoncelli, 6/96. - -function [pyr,pind] = buildLpyr(im, ht, filt1, filt2, edges) - -if (nargin < 1) - error('First argument (IM) is required'); -end - -im_sz = size(im); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('filt1') ~= 1) - filt1 = 'binom5'; -end - -if isstr(filt1) - filt1 = namedFilter(filt1); -end - -if ( (size(filt1,1) > 1) & (size(filt1,2) > 1) ) - error('FILT1 should be a 1D filter (i.e., a vector)'); -else - filt1 = filt1(:); -end - -if (exist('filt2') ~= 1) - filt2 = filt1; -end - -if isstr(filt2) - filt2 = namedFilter(filt2); -end - -if ( (size(filt2,1) > 1) & (size(filt2,2) > 1) ) - error('FILT2 should be a 1D filter (i.e., a vector)'); -else - filt2 = filt2(:); -end - -max_ht = 1 + maxPyrHt(im_sz, max(size(filt1,1), size(filt2,1))); -if ( (exist('ht') ~= 1) | (ht == 'auto') ) - ht = max_ht; -else - if (ht > max_ht) - error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); - end -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end - -%------------------------------------------------------------ - -if (ht <= 1) - - pyr = im(:); - pind = im_sz; - -else - - if (im_sz(2) == 1) - lo2 = corrDn(im, filt1, edges, [2 1], [1 1]); - elseif (im_sz(1) == 1) - lo2 = corrDn(im, filt1', edges, [1 2], [1 1]); - else - lo = corrDn(im, filt1', edges, [1 2], [1 1]); - int_sz = size(lo); - lo2 = corrDn(lo, filt1, edges, [2 1], [1 1]); - end - - [npyr,nind] = buildLpyr(lo2, ht-1, filt1, filt2, edges); - - if (im_sz(1) == 1) - hi2 = upConv(lo2, filt2', edges, [1 2], [1 1], im_sz); - elseif (im_sz(2) == 1) - hi2 = upConv(lo2, filt2, edges, [2 1], [1 1], im_sz); - else - hi = upConv(lo2, filt2, edges, [2 1], [1 1], int_sz); - hi2 = upConv(hi, filt2', edges, [1 2], [1 1], im_sz); - end - - hi2 = im - hi2; - - pyr = [hi2(:); npyr]; - pind = [im_sz; nind]; - -end - diff --git a/evaluation/utils/matlabPyrTools/buildSCFpyr.m b/evaluation/utils/matlabPyrTools/buildSCFpyr.m deleted file mode 100755 index 101b6d2..0000000 --- a/evaluation/utils/matlabPyrTools/buildSCFpyr.m +++ /dev/null @@ -1,90 +0,0 @@ -% [PYR, INDICES, STEERMTX, HARMONICS] = buildSCFpyr(IM, HEIGHT, ORDER, TWIDTH) -% -% This is a modified version of buildSFpyr, that constructs a -% complex-valued steerable pyramid using Hilbert-transform pairs -% of filters. Note that the imaginary parts will *not* be steerable. -% -% To reconstruct from this representation, either call reconSFpyr -% on the real part of the pyramid, *or* call reconSCFpyr which will -% use both real and imaginary parts (forcing analyticity). -% -% Description of this transform appears in: Portilla & Simoncelli, -% Int'l Journal of Computer Vision, 40(1):49-71, Oct 2000. -% Further information: http://www.cns.nyu.edu/~eero/STEERPYR/ - -% Original code: Eero Simoncelli, 5/97. -% Modified by Javier Portilla to return complex (quadrature pair) channels, -% 9/97. - -function [pyr,pind,steermtx,harmonics] = buildSCFpyr(im, ht, order, twidth) - -%----------------------------------------------------------------- -%% DEFAULTS: - -max_ht = floor(log2(min(size(im)))) - 2; - -if (exist('ht') ~= 1) - ht = max_ht; -else - if (ht > max_ht) - error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); - end -end - -if (exist('order') ~= 1) - order = 3; -elseif ((order > 15) | (order < 0)) - fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); - order = min(max(order,0),15); -else - order = round(order); -end -nbands = order+1; - -if (exist('twidth') ~= 1) - twidth = 1; -elseif (twidth <= 0) - fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); - twidth = 1; -end - -%----------------------------------------------------------------- -%% Steering stuff: - -if (mod((nbands),2) == 0) - harmonics = [0:(nbands/2)-1]'*2 + 1; -else - harmonics = [0:(nbands-1)/2]'*2; -end - -steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); - -%----------------------------------------------------------------- - -dims = size(im); -ctr = ceil((dims+0.5)/2); - -[xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... - ([1:dims(1)]-ctr(1))./(dims(1)/2) ); -angle = atan2(yramp,xramp); -log_rad = sqrt(xramp.^2 + yramp.^2); -log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); -log_rad = log2(log_rad); - -%% Radial transition function (a raised cosine in log-frequency): -[Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); -Yrcos = sqrt(Yrcos); - -YIrcos = sqrt(1.0 - Yrcos.^2); -lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); -imdft = fftshift(fft2(im)); -lo0dft = imdft .* lo0mask; - -[pyr,pind] = buildSCFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); - -hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); -hi0dft = imdft .* hi0mask; -hi0 = ifft2(ifftshift(hi0dft)); - -pyr = [real(hi0(:)) ; pyr]; -pind = [size(hi0); pind]; diff --git a/evaluation/utils/matlabPyrTools/buildSCFpyrLevs.m b/evaluation/utils/matlabPyrTools/buildSCFpyrLevs.m deleted file mode 100755 index bd75695..0000000 --- a/evaluation/utils/matlabPyrTools/buildSCFpyrLevs.m +++ /dev/null @@ -1,73 +0,0 @@ -% [PYR, INDICES] = buildSCFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) -% -% Recursive function for constructing levels of a steerable pyramid. This -% is called by buildSCFpyr, and is not usually called directly. - -% Original code: Eero Simoncelli, 5/97. -% Modified by Javier Portilla to generate complex bands in 9/97. - -function [pyr,pind] = buildSCFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); - -if (ht <= 0) - - lo0 = ifft2(ifftshift(lodft)); - pyr = real(lo0(:)); - pind = size(lo0); - -else - - bands = zeros(prod(size(lodft)), nbands); - bind = zeros(nbands,2); - -% log_rad = log_rad + 1; - Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. - - lutsize = 1024; - Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] - order = nbands-1; - %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) - %% Thanks to Patrick Teo for writing this out :) - const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); - -% -% Ycosn = sqrt(const) * (cos(Xcosn)).^order; -% - % analityc version: only take one lobe - alfa= mod(pi+Xcosn,2*pi)-pi; - Ycosn = 2*sqrt(const) * (cos(Xcosn).^order) .* (abs(alfa) max_ht) - error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); - end -end - -if (exist('order') ~= 1) - order = 3; -elseif ((order > 15) | (order < 0)) - fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); - order = min(max(order,0),15); -else - order = round(order); -end -nbands = order+1; - -if (exist('twidth') ~= 1) - twidth = 1; -elseif (twidth <= 0) - fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); - twidth = 1; -end - -%----------------------------------------------------------------- -%% Steering stuff: - -if (mod((nbands),2) == 0) - harmonics = [0:(nbands/2)-1]'*2 + 1; -else - harmonics = [0:(nbands-1)/2]'*2; -end - -steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); - -%----------------------------------------------------------------- - -dims = size(im); -ctr = ceil((dims+0.5)/2); - -[xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... - ([1:dims(1)]-ctr(1))./(dims(1)/2) ); -angle = atan2(yramp,xramp); -log_rad = sqrt(xramp.^2 + yramp.^2); -log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); -log_rad = log2(log_rad); - -%% Radial transition function (a raised cosine in log-frequency): -[Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); -Yrcos = sqrt(Yrcos); - -YIrcos = sqrt(1.0 - Yrcos.^2); -lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); -imdft = fftshift(fft2(im)); -lo0dft = imdft .* lo0mask; - -[pyr,pind] = buildSFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); - -hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); -hi0dft = imdft .* hi0mask; -hi0 = ifft2(ifftshift(hi0dft)); - -pyr = [real(hi0(:)) ; pyr]; -pind = [size(hi0); pind]; diff --git a/evaluation/utils/matlabPyrTools/buildSFpyrLevs.m b/evaluation/utils/matlabPyrTools/buildSFpyrLevs.m deleted file mode 100755 index ad2c8de..0000000 --- a/evaluation/utils/matlabPyrTools/buildSFpyrLevs.m +++ /dev/null @@ -1,63 +0,0 @@ -% [PYR, INDICES] = buildSFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) -% -% Recursive function for constructing levels of a steerable pyramid. This -% is called by buildSFpyr, and is not usually called directly. - -% Eero Simoncelli, 5/97. - -function [pyr,pind] = buildSFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); - -if (ht <= 0) - - lo0 = ifft2(ifftshift(lodft)); - pyr = real(lo0(:)); - pind = size(lo0); - -else - - bands = zeros(prod(size(lodft)), nbands); - bind = zeros(nbands,2); - -% log_rad = log_rad + 1; - Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. - - lutsize = 1024; - Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] - order = nbands-1; - %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) - %% Thanks to Patrick Teo for writing this out :) - const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); - Ycosn = sqrt(const) * (cos(Xcosn)).^order; - himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); - - for b = 1:nbands - anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); - banddft = ((-sqrt(-1))^order) .* lodft .* anglemask .* himask; - band = ifft2(ifftshift(banddft)); - - bands(:,b) = real(band(:)); - bind(b,:) = size(band); - end - - dims = size(lodft); - ctr = ceil((dims+0.5)/2); - lodims = ceil((dims-0.5)/2); - loctr = ceil((lodims+0.5)/2); - lostart = ctr-loctr+1; - loend = lostart+lodims-1; - - log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); - angle = angle(lostart(1):loend(1),lostart(2):loend(2)); - lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); - YIrcos = abs(sqrt(1.0 - Yrcos.^2)); - lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); - - lodft = lomask .* lodft; - - [npyr,nind] = buildSFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); - - pyr = [bands(:); npyr]; - pind = [bind; nind]; - -end - diff --git a/evaluation/utils/matlabPyrTools/buildSpyr.m b/evaluation/utils/matlabPyrTools/buildSpyr.m deleted file mode 100755 index dffc714..0000000 --- a/evaluation/utils/matlabPyrTools/buildSpyr.m +++ /dev/null @@ -1,62 +0,0 @@ -% [PYR, INDICES, STEERMTX, HARMONICS] = buildSpyr(IM, HEIGHT, FILTFILE, EDGES) -% -% Construct a steerable pyramid on matrix IM. Convolutions are -% done with spatial filters. -% -% HEIGHT (optional) specifies the number of pyramid levels to build. Default -% is maxPyrHt(size(IM),size(FILT)). -% You can also specify 'auto' to use this value. -% -% FILTFILE (optional) should be a string referring to an m-file that -% returns the rfilters. (examples: 'sp0Filters', 'sp1Filters', -% 'sp3Filters','sp5Filters'. default = 'sp1Filters'). EDGES specifies -% edge-handling, and defaults to 'reflect1' (see corrDn). -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. -% See the function STEER for a description of STEERMTX and HARMONICS. - -% Eero Simoncelli, 6/96. -% See http://www.cis.upenn.edu/~eero/steerpyr.html for more -% information about the Steerable Pyramid image decomposition. - -function [pyr,pind,steermtx,harmonics] = buildSpyr(im, ht, filtfile, edges) - -%----------------------------------------------------------------- -%% DEFAULTS: - -if (exist('filtfile') ~= 1) - filtfile = 'sp1Filters'; -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end - -if (isstr(filtfile) & (exist(filtfile) == 2)) - [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); -else - fprintf(1,'\nUse buildSFpyr for pyramids with arbitrary numbers of orientation bands.\n'); - error('FILTFILE argument must be the name of an M-file containing SPYR filters.'); -end - -max_ht = maxPyrHt(size(im), size(lofilt,1)); -if ( (exist('ht') ~= 1) | (ht == 'auto') ) - ht = max_ht; -else - if (ht > max_ht) - error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); - end -end - -%----------------------------------------------------------------- - -hi0 = corrDn(im, hi0filt, edges); -lo0 = corrDn(im, lo0filt, edges); - -[pyr,pind] = buildSpyrLevs(lo0, ht, lofilt, bfilts, edges); - -pyr = [hi0(:) ; pyr]; -pind = [size(hi0); pind]; - diff --git a/evaluation/utils/matlabPyrTools/buildSpyrLevs.m b/evaluation/utils/matlabPyrTools/buildSpyrLevs.m deleted file mode 100755 index 4c00077..0000000 --- a/evaluation/utils/matlabPyrTools/buildSpyrLevs.m +++ /dev/null @@ -1,37 +0,0 @@ -% [PYR, INDICES] = buildSpyrLevs(LOIM, HEIGHT, LOFILT, BFILTS, EDGES) -% -% Recursive function for constructing levels of a steerable pyramid. This -% is called by buildSpyr, and is not usually called directly. - -% Eero Simoncelli, 6/96. - -function [pyr,pind] = buildSpyrLevs(lo0,ht,lofilt,bfilts,edges); - -if (ht <= 0) - - pyr = lo0(:); - pind = size(lo0); - -else - - % Assume square filters: - bfiltsz = round(sqrt(size(bfilts,1))); - - bands = zeros(prod(size(lo0)),size(bfilts,2)); - bind = zeros(size(bfilts,2),2); - - for b = 1:size(bfilts,2) - filt = reshape(bfilts(:,b),bfiltsz,bfiltsz); - band = corrDn(lo0, filt, edges); - bands(:,b) = band(:); - bind(b,:) = size(band); - end - - lo = corrDn(lo0, lofilt, edges, [2 2], [1 1]); - - [npyr,nind] = buildSpyrLevs(lo, ht-1, lofilt, bfilts, edges); - - pyr = [bands(:); npyr]; - pind = [bind; nind]; - -end diff --git a/evaluation/utils/matlabPyrTools/buildWpyr.m b/evaluation/utils/matlabPyrTools/buildWpyr.m deleted file mode 100755 index 26a8704..0000000 --- a/evaluation/utils/matlabPyrTools/buildWpyr.m +++ /dev/null @@ -1,100 +0,0 @@ -% [PYR, INDICES] = buildWpyr(IM, HEIGHT, FILT, EDGES) -% -% Construct a separable orthonormal QMF/wavelet pyramid on matrix (or vector) IM. -% -% HEIGHT (optional) specifies the number of pyramid levels to build. Default -% is maxPyrHt(IM,FILT). You can also specify 'auto' to use this value. -% -% FILT (optional) can be a string naming a standard filter (see -% namedFilter), or a vector which will be used for (separable) -% convolution. Filter can be of even or odd length, but should be symmetric. -% Default = 'qmf9'. EDGES specifies edge-handling, and -% defaults to 'reflect1' (see corrDn). -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. - -% Eero Simoncelli, 6/96, based on original lisp code from 1987. - -function [pyr,pind] = buildWpyr(im, ht, filt, edges) - -if (nargin < 1) - error('First argument (IM) is required'); -end - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('filt') ~= 1) - filt = 'qmf9'; -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end - -if isstr(filt) - filt = namedFilter(filt); -end - -if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) - error('FILT should be a 1D filter (i.e., a vector)'); -else - filt = filt(:); -end - -hfilt = modulateFlip(filt); - -% Stagger sampling if filter is odd-length: -if (mod(size(filt,1),2) == 0) - stag = 2; -else - stag = 1; -end - -im_sz = size(im); - -max_ht = maxPyrHt(im_sz, size(filt,1)); -if ( (exist('ht') ~= 1) | (ht == 'auto') ) - ht = max_ht; -else - if (ht > max_ht) - error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); - end -end - -if (ht <= 0) - - pyr = im(:); - pind = im_sz; - -else - - if (im_sz(2) == 1) - lolo = corrDn(im, filt, edges, [2 1], [stag 1]); - hihi = corrDn(im, hfilt, edges, [2 1], [2 1]); - elseif (im_sz(1) == 1) - lolo = corrDn(im, filt', edges, [1 2], [1 stag]); - hihi = corrDn(im, hfilt', edges, [1 2], [1 2]); - else - lo = corrDn(im, filt, edges, [2 1], [stag 1]); - hi = corrDn(im, hfilt, edges, [2 1], [2 1]); - lolo = corrDn(lo, filt', edges, [1 2], [1 stag]); - lohi = corrDn(hi, filt', edges, [1 2], [1 stag]); % horizontal - hilo = corrDn(lo, hfilt', edges, [1 2], [1 2]); % vertical - hihi = corrDn(hi, hfilt', edges, [1 2], [1 2]); % diagonal - end - - [npyr,nind] = buildWpyr(lolo, ht-1, filt, edges); - - if ((im_sz(1) == 1) | (im_sz(2) == 1)) - pyr = [hihi(:); npyr]; - pind = [size(hihi); nind]; - else - pyr = [lohi(:); hilo(:); hihi(:); npyr]; - pind = [size(lohi); size(hilo); size(hihi); nind]; - end - -end - diff --git a/evaluation/utils/matlabPyrTools/cconv2.m b/evaluation/utils/matlabPyrTools/cconv2.m deleted file mode 100755 index efba438..0000000 --- a/evaluation/utils/matlabPyrTools/cconv2.m +++ /dev/null @@ -1,50 +0,0 @@ -% RES = CCONV2(MTX1, MTX2, CTR) -% -% Circular convolution of two matrices. Result will be of size of -% LARGER vector. -% -% The origin of the smaller matrix is assumed to be its center. -% For even dimensions, the origin is determined by the CTR (optional) -% argument: -% CTR origin -% 0 DIM/2 (default) -% 1 (DIM/2)+1 - -% Eero Simoncelli, 6/96. Modified 2/97. - -function c = cconv2(a,b,ctr) - -if (exist('ctr') ~= 1) - ctr = 0; -end - -if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) - large = a; small = b; -elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) - large = b; small = a; -else - error('one arg must be larger than the other in both dimensions!'); -end - -ly = size(large,1); -lx = size(large,2); -sy = size(small,1); -sx = size(small,2); - -%% These values are the index of the small mtx that falls on the -%% border pixel of the large matrix when computing the first -%% convolution response sample: -sy2 = floor((sy+ctr+1)/2); -sx2 = floor((sx+ctr+1)/2); - -% pad: -clarge = [ ... - large(ly-sy+sy2+1:ly,lx-sx+sx2+1:lx), large(ly-sy+sy2+1:ly,:), ... - large(ly-sy+sy2+1:ly,1:sx2-1); ... - large(:,lx-sx+sx2+1:lx), large, large(:,1:sx2-1); ... - large(1:sy2-1,lx-sx+sx2+1:lx), ... - large(1:sy2-1,:), ... - large(1:sy2-1,1:sx2-1) ]; - -c = conv2(clarge,small,'valid'); - diff --git a/evaluation/utils/matlabPyrTools/clip.m b/evaluation/utils/matlabPyrTools/clip.m deleted file mode 100755 index 28804f3..0000000 --- a/evaluation/utils/matlabPyrTools/clip.m +++ /dev/null @@ -1,32 +0,0 @@ -% [RES] = clip(IM, MINVALorRANGE, MAXVAL) -% -% Clip values of matrix IM to lie between minVal and maxVal: -% RES = max(min(IM,MAXVAL),MINVAL) -% The first argument can also specify both min and max, as a 2-vector. -% If only one argument is passed, the range defaults to [0,1]. - -function res = clip(im, minValOrRange, maxVal) - -if (exist('minValOrRange') ~= 1) - minVal = 0; - maxVal = 1; -elseif (length(minValOrRange) == 2) - minVal = minValOrRange(1); - maxVal = minValOrRange(2); -elseif (length(minValOrRange) == 1) - minVal = minValOrRange; - if (exist('maxVal') ~= 1) - maxVal=minVal+1; - end -else - error('MINVAL must be a scalar or a 2-vector'); -end - -if ( maxVal < minVal ) - error('MAXVAL should be less than MINVAL'); -end - -res = im; -res(find(im < minVal)) = minVal; -res(find(im > maxVal)) = maxVal; - diff --git a/evaluation/utils/matlabPyrTools/corrDn.m b/evaluation/utils/matlabPyrTools/corrDn.m deleted file mode 100755 index 1f493d3..0000000 --- a/evaluation/utils/matlabPyrTools/corrDn.m +++ /dev/null @@ -1,63 +0,0 @@ -% RES = corrDn(IM, FILT, EDGES, STEP, START, STOP) -% -% Compute correlation of matrices IM with FILT, followed by -% downsampling. These arguments should be 1D or 2D matrices, and IM -% must be larger (in both dimensions) than FILT. The origin of filt -% is assumed to be floor(size(filt)/2)+1. -% -% EDGES is a string determining boundary handling: -% 'circular' - Circular convolution -% 'reflect1' - Reflect about the edge pixels -% 'reflect2' - Reflect, doubling the edge pixels -% 'repeat' - Repeat the edge pixels -% 'zero' - Assume values of zero outside image boundary -% 'extend' - Reflect and invert (continuous values and derivs) -% 'dont-compute' - Zero output when filter overhangs input boundaries -% -% Downsampling factors are determined by STEP (optional, default=[1 1]), -% which should be a 2-vector [y,x]. -% -% The window over which the convolution occurs is specfied by START -% (optional, default=[1,1], and STOP (optional, default=size(IM)). -% -% NOTE: this operation corresponds to multiplication of a signal -% vector by a matrix whose rows contain copies of the FILT shifted by -% multiples of STEP. See upConv.m for the operation corresponding to -% the transpose of this matrix. - -% Eero Simoncelli, 6/96, revised 2/97. - -function res = corrDn(im, filt, edges, step, start, stop) - -%% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) - -%fprintf(1,'WARNING: You should compile the MEX version of "corrDn.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('edges') == 1) - if (strcmp(edges,'reflect1') ~= 1) - warning('Using REFLECT1 edge-handling (use MEX code for other options).'); - end -end - -if (exist('step') ~= 1) - step = [1,1]; -end - -if (exist('start') ~= 1) - start = [1,1]; -end - -if (exist('stop') ~= 1) - stop = size(im); -end - -%------------------------------------------------------------ - -% Reverse order of taps in filt, to do correlation instead of convolution -filt = filt(size(filt,1):-1:1,size(filt,2):-1:1); - -tmp = rconv2(im,filt); -res = tmp(start(1):step(1):stop(1),start(2):step(2):stop(2)); diff --git a/evaluation/utils/matlabPyrTools/corrDn.mexa64 b/evaluation/utils/matlabPyrTools/corrDn.mexa64 deleted file mode 100755 index 94dc932..0000000 Binary files a/evaluation/utils/matlabPyrTools/corrDn.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/corrDn.mexglx b/evaluation/utils/matlabPyrTools/corrDn.mexglx deleted file mode 100755 index 7a1decd..0000000 Binary files a/evaluation/utils/matlabPyrTools/corrDn.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/corrDn.mexmac b/evaluation/utils/matlabPyrTools/corrDn.mexmac deleted file mode 100755 index 75a5407..0000000 Binary files a/evaluation/utils/matlabPyrTools/corrDn.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/corrDn.mexmaci64 b/evaluation/utils/matlabPyrTools/corrDn.mexmaci64 deleted file mode 100755 index 291afad..0000000 Binary files a/evaluation/utils/matlabPyrTools/corrDn.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/corrDn.mexw32 b/evaluation/utils/matlabPyrTools/corrDn.mexw32 deleted file mode 100755 index 5140651..0000000 Binary files a/evaluation/utils/matlabPyrTools/corrDn.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/einstein.pgm b/evaluation/utils/matlabPyrTools/einstein.pgm deleted file mode 100755 index 99b974c..0000000 Binary files a/evaluation/utils/matlabPyrTools/einstein.pgm and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/entropy2.m b/evaluation/utils/matlabPyrTools/entropy2.m deleted file mode 100755 index 78b0325..0000000 --- a/evaluation/utils/matlabPyrTools/entropy2.m +++ /dev/null @@ -1,31 +0,0 @@ -% E = ENTROPY2(MTX,BINSIZE) -% -% Compute the first-order sample entropy of MTX. Samples of VEC are -% first discretized. Optional argument BINSIZE controls the -% discretization, and defaults to 256/(max(VEC)-min(VEC)). -% -% NOTE: This is a heavily biased estimate of entropy (it is too -% small) when you don't have much data! - -% Eero Simoncelli, 6/96. - -function res = entropy2(mtx,binsize) - -%% Ensure it's a vector, not a matrix. -vec = mtx(:); -[mn,mx] = range2(vec); - -if (exist('binsize') == 1) - nbins = max((mx-mn)/binsize, 1); -else - nbins = 256; -end - -[bincount,bins] = histo(vec,nbins); - -%% Collect non-zero bins: -H = bincount(find(bincount)); -H = H/sum(H); - -res = -sum(H .* log2(H)); - diff --git a/evaluation/utils/matlabPyrTools/factorial.m b/evaluation/utils/matlabPyrTools/factorial.m deleted file mode 100755 index 9255f43..0000000 --- a/evaluation/utils/matlabPyrTools/factorial.m +++ /dev/null @@ -1,16 +0,0 @@ -%% RES = factorial(NUM) -% -% Factorial function that works on matrices (matlab's does not). - -% EPS, 11/02 - -function res = factorial(num) - -res = ones(size(num)); - -ind = find(num > 0); -if ( ~isempty(ind) ) - subNum = num(ind); - res(ind) = subNum .* factorial(subNum-1); -end - diff --git a/evaluation/utils/matlabPyrTools/feynman.pgm b/evaluation/utils/matlabPyrTools/feynman.pgm deleted file mode 100755 index 7d14101..0000000 Binary files a/evaluation/utils/matlabPyrTools/feynman.pgm and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/histo.m b/evaluation/utils/matlabPyrTools/histo.m deleted file mode 100755 index 3366301..0000000 --- a/evaluation/utils/matlabPyrTools/histo.m +++ /dev/null @@ -1,58 +0,0 @@ -% [N,X] = histo(MTX, nbinsOrBinsize, binCenter); -% -% Compute a histogram of (all) elements of MTX. N contains the histogram -% counts, X is a vector containg the centers of the histogram bins. -% -% nbinsOrBinsize (optional, default = 101) specifies either -% the number of histogram bins, or the negative of the binsize. -% -% binCenter (optional, default = mean2(MTX)) specifies a center position -% for (any one of) the histogram bins. -% -% How does this differ from MatLab's HIST function? This function: -% - allows uniformly spaced bins only. -% +/- operates on all elements of MTX, instead of columnwise. -% + is much faster (approximately a factor of 80 on my machine). -% + allows specification of number of bins OR binsize. Default=101 bins. -% + allows (optional) specification of binCenter. - -% Eero Simoncelli, 3/97. - -function [N, X] = histo(mtx, nbins, binCtr) - -%% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) - -fprintf(1,'WARNING: You should compile the MEX version of "histo.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); - -mtx = mtx(:); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -[mn,mx] = range2(mtx); - -if (exist('binCtr') ~= 1) - binCtr = mean(mtx); -end - -if (exist('nbins') == 1) - if (nbins < 0) - binSize = -nbins; - else - binSize = ((mx-mn)/nbins); - tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); - if (tmpNbins ~= nbins) - warning('Using %d bins instead of requested number (%d)',tmpNbins,nbins); - end - end -else - binSize = ((mx-mn)/101); -end - -firstBin = binCtr + binSize*round( (mn-binCtr)/binSize ); - -tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); - -bins = firstBin + binSize*[0:tmpNbins]; - -[N, X] = hist(mtx, bins); diff --git a/evaluation/utils/matlabPyrTools/histo.mexa64 b/evaluation/utils/matlabPyrTools/histo.mexa64 deleted file mode 100755 index ac65ceb..0000000 Binary files a/evaluation/utils/matlabPyrTools/histo.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/histo.mexglx b/evaluation/utils/matlabPyrTools/histo.mexglx deleted file mode 100755 index 4d67bfe..0000000 Binary files a/evaluation/utils/matlabPyrTools/histo.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/histo.mexmac b/evaluation/utils/matlabPyrTools/histo.mexmac deleted file mode 100755 index 9c9d47a..0000000 Binary files a/evaluation/utils/matlabPyrTools/histo.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/histo.mexmaci64 b/evaluation/utils/matlabPyrTools/histo.mexmaci64 deleted file mode 100755 index 7e399c6..0000000 Binary files a/evaluation/utils/matlabPyrTools/histo.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/histo.mexw32 b/evaluation/utils/matlabPyrTools/histo.mexw32 deleted file mode 100755 index 03663ef..0000000 Binary files a/evaluation/utils/matlabPyrTools/histo.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/histoMatch.m b/evaluation/utils/matlabPyrTools/histoMatch.m deleted file mode 100755 index ab82782..0000000 --- a/evaluation/utils/matlabPyrTools/histoMatch.m +++ /dev/null @@ -1,35 +0,0 @@ -% RES = histoMatch(MTX, N, X) -% -% Modify elements of MTX so that normalized histogram matches that -% specified by vectors X and N, where N contains the histogram counts -% and X the histogram bin positions (see histo). - -% Eero Simoncelli, 7/96. - -function res = histoMatch(mtx, N, X) - -if ( exist('histo') == 3 ) - [oN, oX] = histo(mtx(:), size(X(:),1)); -else - [oN, oX] = hist(mtx(:), size(X(:),1)); -end - -oStep = oX(2) - oX(1); -oC = [0, cumsum(oN)]/sum(oN); -oX = [oX(1)-oStep/2, oX+oStep/2]; - -N = N(:)'; -X = X(:)'; -N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic - -nStep = X(2) - X(1); -nC = [0, cumsum(N)]/sum(N); -nX = [X(1)-nStep/2, X+nStep/2]; - -nnX = interp1(nC, nX, oC, 'linear'); - -if ( exist('pointOp') == 3 ) - res = pointOp(mtx, nnX, oX(1), oStep); -else - res = reshape(interp1(oX, nnX, mtx(:)),size(mtx,1),size(mtx,2)); -end diff --git a/evaluation/utils/matlabPyrTools/imGradient.m b/evaluation/utils/matlabPyrTools/imGradient.m deleted file mode 100755 index a120552..0000000 --- a/evaluation/utils/matlabPyrTools/imGradient.m +++ /dev/null @@ -1,50 +0,0 @@ -% [dx, dy] = imGradient(im, edges) -% -% Compute the gradient of the image using smooth derivative filters -% optimized for accurate direction estimation. Coordinate system -% corresponds to standard pixel indexing: X axis points rightward. Y -% axis points downward. EDGES specify boundary handling (see corrDn -% for options). -% -% Unlike matlab's new gradient function, which is based on local -% differences, this function computes derivatives using 5x5 filters -% designed to accurately reflect the local orientation content. - -% EPS, 1997. -% original filters from Int'l Conf Image Processing, 1994. -% updated filters 10/2003: see Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. -% Incorporated into matlabPyrTools 10/2004. - -function [dx, dy] = imGradient(im, edges) - -if (exist('edges') ~= 1) - edges = 'dont-compute'; -end - -%% kernels from Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. -gp = [0.037659 0.249153 0.426375 0.249153 0.037659]'; -gd = [-0.109604 -0.276691 0.000000 0.276691 0.109604]'; - -dx = corrDn(corrDn(im, gp, edges), gd', edges); -dy = corrDn(corrDn(im, gd, edges), gp', edges); - -return - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% TEST: - -%%Make a ramp with random slope and direction -dir = 2*pi*rand - pi; -slope = 10*rand; - -sz = 32 -im = mkRamp(sz, dir, slope); -[dx,dy] = imGradient(im); -showIm(dx + sqrt(-1)*dy); - -ctr = (sz*sz/2)+sz/2; -slopeEst = sqrt(dx(ctr).^2 + dy(ctr).^2); -dirEst = atan2(dy(ctr), dx(ctr)); - -[slope, slopeEst] -[dir, dirEst] diff --git a/evaluation/utils/matlabPyrTools/imStats.m b/evaluation/utils/matlabPyrTools/imStats.m deleted file mode 100755 index bd2841f..0000000 --- a/evaluation/utils/matlabPyrTools/imStats.m +++ /dev/null @@ -1,43 +0,0 @@ -% imStats(IM1,IM2) -% -% Report image (matrix) statistics. -% When called on a single image IM1, report min, max, mean, stdev, skew, -% and kurtosis (4th moment about the mean, divided by squared variance) -% -% When called on two images (IM1 and IM2), report min, max, mean, -% stdev of the difference, and also SNR (relative to IM1). - -% Eero Simoncelli, 6/96. - -function [] = imStats(im1,im2) - -if (~isreal(im1)) - error('Args must be real-valued matrices'); -end - -if (exist('im2') == 1) - difference = im1 - im2; - [mn,mx] = range2(difference); - mean = mean2(difference); - v = var2(difference,mean); - if (v < realmin) - snr = Inf; - else - snr = 10 * log10(var2(im1)/v); - end - fprintf(1, 'Difference statistics:\n'); - fprintf(1, ' Range: [%c, %c]\n',mn,mx); - fprintf(1, ' Mean: %f, Stdev (rmse): %f, SNR (dB): %f\n',... - mean,sqrt(v),snr); -else - [mn,mx] = range2(im1); - mean = mean2(im1); - var = var2(im1,mean); - stdev = sqrt(real(var))+sqrt(imag(var)); - sk = skew2(im1, mean, stdev^2); - kurt = kurt2(im1, mean, stdev^2); - fprintf(1, 'Image statistics:\n'); - fprintf(1, ' Range: [%f, %f]\n',mn,mx); - fprintf(1, ' Mean: %f, Stdev: %f, Skew: %f, Kurt: %f\n',mean,stdev,sk,kurt); -end - diff --git a/evaluation/utils/matlabPyrTools/innerProd.m b/evaluation/utils/matlabPyrTools/innerProd.m deleted file mode 100755 index 11bb8f8..0000000 --- a/evaluation/utils/matlabPyrTools/innerProd.m +++ /dev/null @@ -1,11 +0,0 @@ -% RES = innerProd(MTX) -% -% Compute (MTX' * MTX) efficiently (i.e., without copying the matrix) -% -% NOTE: This function used to call a MEX function (C code) to avoid copying, but -% newer versions of matlab have eliminated the overhead of the -% simpler form below. - -function res = innerProd(mtx) - -res = mtx' * mtx; diff --git a/evaluation/utils/matlabPyrTools/kurt2.m b/evaluation/utils/matlabPyrTools/kurt2.m deleted file mode 100755 index 8351eb4..0000000 --- a/evaluation/utils/matlabPyrTools/kurt2.m +++ /dev/null @@ -1,24 +0,0 @@ -% K = KURT2(MTX,MEAN,VAR) -% -% Sample kurtosis (fourth moment divided by squared variance) -% of a matrix. Kurtosis of a Gaussian distribution is 3. -% MEAN (optional) and VAR (optional) make the computation faster. - -% Eero Simoncelli, 6/96. - -function res = kurt2(mtx, mn, v) - -if (exist('mn') ~= 1) - mn = mean(mean(mtx)); -end - -if (exist('v') ~= 1) - v = var2(mtx,mn); -end - -if (isreal(mtx)) - res = mean(mean(abs(mtx-mn).^4)) / (v^2); -else - res = mean(mean(real(mtx-mn).^4)) / (real(v)^2) + ... - i*mean(mean(imag(mtx-mn).^4)) / (imag(v)^2); -end diff --git a/evaluation/utils/matlabPyrTools/lplot.m b/evaluation/utils/matlabPyrTools/lplot.m deleted file mode 100755 index f922a56..0000000 --- a/evaluation/utils/matlabPyrTools/lplot.m +++ /dev/null @@ -1,43 +0,0 @@ -% lplot(VEC, XRANGE) -% -% Plot VEC, a vector, in "lollipop" format. -% XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector -% specifying the X positions (for labeling purposes) of the first and -% last sample of VEC. - -% Mark Liberman, Linguistics Dept, UPenn, 1994. - -function lplot(x,xrange) - -if (exist('xrange') ~= 1) - xrange = [1,length(x)]; -end - -msize = size(x); -if ( msize(2) == 1) - x = x'; -elseif (msize(1) ~= 1) - error('First arg must be a vector'); -end - -if (~isreal(x)) - fprintf(1,'Warning: Imaginary part of signal ignored\n'); - x = abs(x); -end - -N = length(x); -index = xrange(1) + (xrange(2)-xrange(1))*[0:(N-1)]/(N-1); -xinc = index(2)-index(1); - -xx = [zeros(1,N);x;zeros(1,N)]; -indexis = [index;index;index]; -xdiscrete = [0 xx(:)' 0]; -idiscrete = [index(1)-xinc indexis(:)' index(N)+xinc]; - -[mn,mx] = range2(xdiscrete); -ypad = (mx-mn)/12; % MAGIC NUMBER: graph padding - -plot(idiscrete, xdiscrete, index, x, 'o'); -axis([index(1)-xinc, index(N)+xinc, mn-ypad, mx+ypad]); - -return diff --git a/evaluation/utils/matlabPyrTools/lpyrHt.m b/evaluation/utils/matlabPyrTools/lpyrHt.m deleted file mode 100755 index d6834d7..0000000 --- a/evaluation/utils/matlabPyrTools/lpyrHt.m +++ /dev/null @@ -1,11 +0,0 @@ -% [HEIGHT] = lpyrHt(INDICES) -% -% Compute height of Laplacian pyramid with given its INDICES matrix. -% See buildLpyr.m - -% Eero Simoncelli, 6/96. - -function [ht] = lpyrHt(pind) - -% Don't count lowpass residual band -ht = size(pind,1)-1; diff --git a/evaluation/utils/matlabPyrTools/make-tar-file b/evaluation/utils/matlabPyrTools/make-tar-file deleted file mode 100755 index 6338b76..0000000 --- a/evaluation/utils/matlabPyrTools/make-tar-file +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/csh -f - -setenv BASENAME "/lcv/matlab/lib/" - -setenv DIRNAME "matlabPyrTools" -setenv TARFILE "matlabPyrTools.tar" - -# For MAC: -# Put Macintosh-MEX.sit.hqx (contains projects, C code, mex files) inside of -# MEX directory. -# Put matlabPyrTools.sit.hqx (entire distribution, filetype corrected, no -# MEX subdirectory) inside of main directory. - -#################################################################### -## Make a compressed tar file of the EPS_matlab directory: - -echo "Before making the tar file:" -echo "1) If C code is modified, re-make the mex files..." -echo "2) Put correct date and version number in Contents.m. Execute 'ver' to test" -echo "3) add a ChangeLog entry stating that new tarfile was generated" -sleep 5 - -pushd ${BASENAME} - -#echo "Removing old tarfile..." -#/bin/rm "${DIRNAME}/${TARFILE}" -#/bin/rm "${DIRNAME}/${TARFILE}.gz" - -#echo "Removing ${DIRNAME}/MEX/*.o files..." -#/bin/rm ${DIRNAME}/MEX/*.o - -echo "Creating ${DIRNAME}/${TARFILE} ..." - -tar -cvf ${DIRNAME}/${TARFILE} \ - ${DIRNAME}/README ${DIRNAME}/ChangeLog ${DIRNAME}/*.m \ - ${DIRNAME}/MEX \ - ${DIRNAME}/TUTORIALS/README ${DIRNAME}/TUTORIALS/*.m \ - ${DIRNAME}/*.pgm - -echo "G'zipping ${DIRNAME}/${TARFILE} ..." - -gzip ${DIRNAME}/$TARFILE -gls -l "${DIRNAME}/$TARFILE.gz" - -popd - -echo "Done. Now:" -echo " cd ${BASENAME}/${DIRNAME}" -echo " scp ${TARFILE}.gz hopf:/Library/WebServer/Documents-www/ftp/eero/" -echo " cp README /users/eero/html_public/matlabPyrTools.README" -echo " cp ChangeLog /users/eero/html_public/matlabPyrTools.ChangeLog" -echo " cp Contents.m /users/eero/html_public/matlabPyrTools-Contents.m" -echo "" -echo " Finally, mark as updated in ~lcv/html_public/software.html" -echo "" diff --git a/evaluation/utils/matlabPyrTools/maxPyrHt.m b/evaluation/utils/matlabPyrTools/maxPyrHt.m deleted file mode 100755 index 84bcf29..0000000 --- a/evaluation/utils/matlabPyrTools/maxPyrHt.m +++ /dev/null @@ -1,25 +0,0 @@ -% HEIGHT = maxPyrHt(IMSIZE, FILTSIZE) -% -% Compute maximum pyramid height for given image and filter sizes. -% Specifically: the number of corrDn operations that can be sequentially -% performed when subsampling by a factor of 2. - -% Eero Simoncelli, 6/96. - -function height = maxPyrHt(imsz, filtsz) - -imsz = imsz(:); -filtsz = filtsz(:); - -if any(imsz == 1) % 1D image - imsz = prod(imsz); - filtsz = prod(filtsz); -elseif any(filtsz == 1) % 2D image, 1D filter - filtsz = [filtsz(1); filtsz(1)]; -end - -if any(imsz < filtsz) - height = 0; -else - height = 1 + maxPyrHt( floor(imsz/2), filtsz ); -end diff --git a/evaluation/utils/matlabPyrTools/mean2.m b/evaluation/utils/matlabPyrTools/mean2.m deleted file mode 100755 index 177f7ac..0000000 --- a/evaluation/utils/matlabPyrTools/mean2.m +++ /dev/null @@ -1,7 +0,0 @@ -% M = MEAN2(MTX) -% -% Sample mean of a matrix. - -function res = mean2(mtx) - -res = mean(mean(mtx)); diff --git a/evaluation/utils/matlabPyrTools/mkAngle.m b/evaluation/utils/matlabPyrTools/mkAngle.m deleted file mode 100755 index bd54f8d..0000000 --- a/evaluation/utils/matlabPyrTools/mkAngle.m +++ /dev/null @@ -1,32 +0,0 @@ -% IM = mkAngle(SIZE, PHASE, ORIGIN) -% -% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) -% containing samples of the polar angle (in radians, CW from the -% X-axis, ranging from -pi to pi), relative to angle PHASE (default = -% 0), about ORIGIN pixel (default = (size+1)/2). - -% Eero Simoncelli, 6/96. - -function [res] = mkAngle(sz, phase, origin) - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz,sz]; -end - -% ----------------------------------------------------------------- -% OPTIONAL args: - -if (exist('origin') ~= 1) - origin = (sz+1)/2; -end - -% ----------------------------------------------------------------- - -[xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); - -res = atan2(yramp,xramp); - -if (exist('phase') == 1) - res = mod(res+(pi-phase),2*pi)-pi; -end diff --git a/evaluation/utils/matlabPyrTools/mkAngularSine.m b/evaluation/utils/matlabPyrTools/mkAngularSine.m deleted file mode 100755 index f5238cc..0000000 --- a/evaluation/utils/matlabPyrTools/mkAngularSine.m +++ /dev/null @@ -1,42 +0,0 @@ -% IM = mkAngularSine(SIZE, HARMONIC, AMPL, PHASE, ORIGIN) -% -% Make an angular sinusoidal image: -% AMPL * sin( HARMONIC*theta + PHASE), -% where theta is the angle about the origin. -% SIZE specifies the matrix size, as for zeros(). -% AMPL (default = 1) and PHASE (default = 0) are optional. - -% Eero Simoncelli, 2/97. - -function [res] = mkAngularSine(sz, harmonic, ampl, ph, origin) - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz,sz]; -end - -mxsz = max(sz(1),sz(2)); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('harmonic') ~= 1) - harmonic = 1; -end - -if (exist('ampl') ~= 1) - ampl = 1; -end - -if (exist('ph') ~= 1) - ph = 0; -end - -if (exist('origin') ~= 1) - origin = (sz+1)/2; -end - -%------------------------------------------------------------ - -res = ampl * sin(harmonic*mkAngle(sz,ph,origin) + ph); - diff --git a/evaluation/utils/matlabPyrTools/mkDisc.m b/evaluation/utils/matlabPyrTools/mkDisc.m deleted file mode 100755 index 33e7d6d..0000000 --- a/evaluation/utils/matlabPyrTools/mkDisc.m +++ /dev/null @@ -1,61 +0,0 @@ -% IM = mkDisc(SIZE, RADIUS, ORIGIN, TWIDTH, VALS) -% -% Make a "disk" image. SIZE specifies the matrix size, as for -% zeros(). RADIUS (default = min(size)/4) specifies the radius of -% the disk. ORIGIN (default = (size+1)/2) specifies the -% location of the disk center. TWIDTH (in pixels, default = 2) -% specifies the width over which a soft threshold transition is made. -% VALS (default = [0,1]) should be a 2-vector containing the -% intensity value inside and outside the disk. - -% Eero Simoncelli, 6/96. - -function [res] = mkDisc(sz, rad, origin, twidth, vals) - -if (nargin < 1) - error('Must pass at least a size argument'); -end - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz sz]; -end - -%------------------------------------------------------------ -% OPTIONAL ARGS: - -if (exist('rad') ~= 1) - rad = min(sz(1),sz(2))/4; -end - -if (exist('origin') ~= 1) - origin = (sz+1)./2; -end - -if (exist('twidth') ~= 1) - twidth = 2; -end - -if (exist('vals') ~= 1) - vals = [1,0]; -end - -%------------------------------------------------------------ - -res = mkR(sz,1,origin); - -if (abs(twidth) < realmin) - res = vals(2) + (vals(1) - vals(2)) * (res <= rad); -else - [Xtbl,Ytbl] = rcosFn(twidth, rad, [vals(1), vals(2)]); - res = pointOp(res, Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0); -% -% OLD interp1 VERSION: -% res = res(:); -% Xtbl(1) = min(res); -% Xtbl(size(Xtbl,2)) = max(res); -% res = reshape(interp1(Xtbl,Ytbl,res), sz(1), sz(2)); -% -end - - diff --git a/evaluation/utils/matlabPyrTools/mkFract.m b/evaluation/utils/matlabPyrTools/mkFract.m deleted file mode 100755 index af95cd5..0000000 --- a/evaluation/utils/matlabPyrTools/mkFract.m +++ /dev/null @@ -1,36 +0,0 @@ -% IM = mkFract(SIZE, FRACT_DIM) -% -% Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar) -% containing fractal (pink) noise with power spectral density of the -% form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0. -% FRACT_DIM defaults to 1.0 - -% Eero Simoncelli, 6/96. - -%% TODO: Verify that this matches Mandelbrot defn of fractal dimension. -%% Make this more efficient! - -function res = mkFract(dims, fract_dim) - -if (exist('fract_dim') ~= 1) - fract_dim = 1.0; -end - -res = randn(dims); -fres = fft2(res); - -sz = size(res); -ctr = ceil((sz+1)./2); - -shape = ifftshift(mkR(sz, -(2.5-fract_dim), ctr)); -shape(1,1) = 1; %%DC term - -fres = shape .* fres; -fres = ifft2(fres); - -if (max(max(abs(imag(fres)))) > 1e-10) - error('Symmetry error in creating fractal'); -else - res = real(fres); - res = res / sqrt(var2(res)); -end diff --git a/evaluation/utils/matlabPyrTools/mkGaussian.m b/evaluation/utils/matlabPyrTools/mkGaussian.m deleted file mode 100755 index a35728f..0000000 --- a/evaluation/utils/matlabPyrTools/mkGaussian.m +++ /dev/null @@ -1,63 +0,0 @@ -% IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE) -% -% Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a -% scalar) containing a Gaussian function, centered at pixel position -% specified by MEAN (default = (size+1)/2), with given COVARIANCE (can -% be a scalar, 2-vector, or 2x2 matrix. Default = (min(size)/6)^2), -% and AMPLITUDE. AMPLITUDE='norm' (default) will produce a -% probability-normalized function. All but the first argument are -% optional. - -% Eero Simoncelli, 6/96. - -function [res] = mkGaussian(sz, cov, mn, ampl) - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz,sz]; -end - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('cov') ~= 1) - cov = (min(sz(1),sz(2))/6)^2; -end - -if ( (exist('mn') ~= 1) | isempty(mn) ) - mn = (sz+1)/2; -else - mn = mn(:); - if (size(mn,1) == 1) - mn = [mn, mn]; - end -end - -if (exist('ampl') ~= 1) - ampl = 'norm'; -end - -%------------------------------------------------------------ - -[xramp,yramp] = meshgrid([1:sz(2)]-mn(2),[1:sz(1)]-mn(1)); - -if (sum(size(cov)) == 2) % scalar - if (strcmp(ampl,'norm')) - ampl = 1/(2*pi*cov(1)); - end - e = (xramp.^2 + yramp.^2)/(-2 * cov); -elseif (sum(size(cov)) == 3) % a 2-vector - if (strcmp(ampl,'norm')) - ampl = 1/(2*pi*sqrt(cov(1)*cov(2))); - end - e = xramp.^2/(-2 * cov(2)) + yramp.^2/(-2 * cov(1)); -else - if (strcmp(ampl,'norm')) - ampl = 1/(2*pi*sqrt(det(cov))); - end - cov = -inv(cov)/2; - e = cov(2,2)*xramp.^2 + (cov(1,2)+cov(2,1))*(xramp.*yramp) ... - + cov(1,1)*yramp.^2; -end - -res = ampl .* exp(e); diff --git a/evaluation/utils/matlabPyrTools/mkImpulse.m b/evaluation/utils/matlabPyrTools/mkImpulse.m deleted file mode 100755 index 9844ee8..0000000 --- a/evaluation/utils/matlabPyrTools/mkImpulse.m +++ /dev/null @@ -1,25 +0,0 @@ -% IM = mkImpulse(SIZE, ORIGIN, AMPLITUDE) -% -% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) -% containing a single non-zero entry, at position ORIGIN (defaults to -% ceil(size/2)), of value AMPLITUDE (defaults to 1). - -% Eero Simoncelli, 6/96. - -function [res] = mkImpulse(sz, origin, amplitude) - -sz = sz(:)'; -if (size(sz,2) == 1) - sz = [sz sz]; -end - -if (exist('origin') ~= 1) - origin = ceil(sz/2); -end - -if (exist('amplitude') ~= 1) - amplitude = 1; -end - -res = zeros(sz); -res(origin(1),origin(2)) = amplitude; diff --git a/evaluation/utils/matlabPyrTools/mkR.m b/evaluation/utils/matlabPyrTools/mkR.m deleted file mode 100755 index a1e8448..0000000 --- a/evaluation/utils/matlabPyrTools/mkR.m +++ /dev/null @@ -1,32 +0,0 @@ -% IM = mkR(SIZE, EXPT, ORIGIN) -% -% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) -% containing samples of a radial ramp function, raised to power EXPT -% (default = 1), with given ORIGIN (default = (size+1)/2, [1 1] = -% upper left). All but the first argument are optional. - -% Eero Simoncelli, 6/96. - -function [res] = mkR(sz, expt, origin) - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz,sz]; -end - -% ----------------------------------------------------------------- -% OPTIONAL args: - -if (exist('expt') ~= 1) - expt = 1; -end - -if (exist('origin') ~= 1) - origin = (sz+1)/2; -end - -% ----------------------------------------------------------------- - -[xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); - -res = (xramp.^2 + yramp.^2).^(expt/2); diff --git a/evaluation/utils/matlabPyrTools/mkRamp.m b/evaluation/utils/matlabPyrTools/mkRamp.m deleted file mode 100755 index dd37164..0000000 --- a/evaluation/utils/matlabPyrTools/mkRamp.m +++ /dev/null @@ -1,47 +0,0 @@ -% IM = mkRamp(SIZE, DIRECTION, SLOPE, INTERCEPT, ORIGIN) -% -% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) -% containing samples of a ramp function, with given gradient DIRECTION -% (radians, CW from X-axis, default = 0), SLOPE (per pixel, default = -% 1), and a value of INTERCEPT (default = 0) at the ORIGIN (default = -% (size+1)/2, [1 1] = upper left). All but the first argument are -% optional. - -% Eero Simoncelli, 6/96. 2/97: adjusted coordinate system. - -function [res] = mkRamp(sz, dir, slope, intercept, origin) - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz,sz]; -end - -% ----------------------------------------------------------------- -% OPTIONAL args: - -if (exist('dir') ~= 1) - dir = 0; -end - -if (exist('slope') ~= 1) - slope = 1; -end - -if (exist('intercept') ~= 1) - intercept = 0; -end - -if (exist('origin') ~= 1) - origin = (sz+1)/2; -end - -% ----------------------------------------------------------------- - -xinc = slope*cos(dir); -yinc = slope*sin(dir); - -[xramp,yramp] = meshgrid( xinc*([1:sz(2)]-origin(2)), ... - yinc*([1:sz(1)]-origin(1)) ); - -res = intercept + xramp + yramp; - diff --git a/evaluation/utils/matlabPyrTools/mkSine.m b/evaluation/utils/matlabPyrTools/mkSine.m deleted file mode 100755 index 147eb01..0000000 --- a/evaluation/utils/matlabPyrTools/mkSine.m +++ /dev/null @@ -1,67 +0,0 @@ -% IM = mkSine(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN) -% or -% IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN) -% -% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) -% containing samples of a 2D sinusoid, with given PERIOD (in pixels), -% DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE (default -% = 1), and PHASE (radians, relative to ORIGIN, default = 0). ORIGIN -% defaults to the center of the image. -% -% In the second form, FREQ is a 2-vector of frequencies (radians/pixel). - -% Eero Simoncelli, 6/96. - -function [res] = mkSine(sz, per_freq, dir_amp, amp_phase, phase_orig, orig) - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (prod(size(per_freq)) == 2) - frequency = norm(per_freq); - direction = atan2(per_freq(1),per_freq(2)); - if (exist('dir_amp') == 1) - amplitude = dir_amp; - else - amplitude = 1; - end - if (exist('amp_phase') == 1) - phase = amp_phase; - else - phase = 0; - end - if (exist('phase_orig') == 1) - origin = phase_orig; - end - if (exist('orig') == 1) - error('Too many arguments for (second form) of mkSine'); - end -else - frequency = 2*pi/per_freq; - if (exist('dir_amp') == 1) - direction = dir_amp; - else - direction = 0; - end - if (exist('amp_phase') == 1) - amplitude = amp_phase; - else - amplitude = 1; - end - if (exist('phase_orig') == 1) - phase = phase_orig; - else - phase = 0; - end - if (exist('orig') == 1) - origin = orig; - end -end - -%------------------------------------------------------------ - -if (exist('origin') == 1) - res = amplitude*sin(mkRamp(sz, direction, frequency, phase, origin)); -else - res = amplitude*sin(mkRamp(sz, direction, frequency, phase)); -end diff --git a/evaluation/utils/matlabPyrTools/mkSquare.m b/evaluation/utils/matlabPyrTools/mkSquare.m deleted file mode 100755 index 84ef466..0000000 --- a/evaluation/utils/matlabPyrTools/mkSquare.m +++ /dev/null @@ -1,89 +0,0 @@ -% IM = mkSquare(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN, TWIDTH) -% or -% IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN, TWIDTH) -% -% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) -% containing samples of a 2D square wave, with given PERIOD (in -% pixels), DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE -% (default = 1), and PHASE (radians, relative to ORIGIN, default = 0). -% ORIGIN defaults to the center of the image. TWIDTH specifies width -% of raised-cosine edges on the bars of the grating (default = -% min(2,period/3)). -% -% In the second form, FREQ is a 2-vector of frequencies (radians/pixel). - -% Eero Simoncelli, 6/96. - -% TODO: Add duty cycle. - -function [res] = mkSquare(sz, per_freq, dir_amp, amp_phase, phase_orig, orig_twidth, twidth) - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (prod(size(per_freq)) == 2) - frequency = norm(per_freq); - direction = atan2(per_freq(1),per_freq(2)); - if (exist('dir_amp') == 1) - amplitude = dir_amp; - else - amplitude = 1; - end - if (exist('amp_phase') == 1) - phase = amp_phase; - else - phase = 0; - end - if (exist('phase_orig') == 1) - origin = phase_orig; - end - if (exist('orig_twidth') == 1) - transition = orig_twidth; - else - transition = min(2,2*pi/(3*frequency)); - end - if (exist('twidth') == 1) - error('Too many arguments for (second form) of mkSine'); - end -else - frequency = 2*pi/per_freq; - if (exist('dir_amp') == 1) - direction = dir_amp; - else - direction = 0; - end - if (exist('amp_phase') == 1) - amplitude = amp_phase; - else - amplitude = 1; - end - if (exist('phase_orig') == 1) - phase = phase_orig; - else - phase = 0; - end - if (exist('orig_twidth') == 1) - origin = orig_twidth; - end - if (exist('twidth') == 1) - transition = twidth; - else - transition = min(2,2*pi/(3*frequency)); - end - -end - -%------------------------------------------------------------ - -if (exist('origin') == 1) - res = mkRamp(sz, direction, frequency, phase, origin) - pi/2; -else - res = mkRamp(sz, direction, frequency, phase) - pi/2; -end - -[Xtbl,Ytbl] = rcosFn(transition*frequency,pi/2,[-amplitude amplitude]); - -res = pointOp(abs(mod(res+pi, 2*pi)-pi),Ytbl,Xtbl(1),Xtbl(2)-Xtbl(1),0); - -% OLD threshold version: -%res = amplitude * (mod(res,2*pi) < pi); diff --git a/evaluation/utils/matlabPyrTools/mkZonePlate.m b/evaluation/utils/matlabPyrTools/mkZonePlate.m deleted file mode 100755 index 2b6a4a5..0000000 --- a/evaluation/utils/matlabPyrTools/mkZonePlate.m +++ /dev/null @@ -1,33 +0,0 @@ -% IM = mkZonePlate(SIZE, AMPL, PHASE) -% -% Make a "zone plate" image: -% AMPL * cos( r^2 + PHASE) -% SIZE specifies the matrix size, as for zeros(). -% AMPL (default = 1) and PHASE (default = 0) are optional. - -% Eero Simoncelli, 6/96. - -function [res] = mkZonePlate(sz, ampl, ph) - -sz = sz(:); -if (size(sz,1) == 1) - sz = [sz,sz]; -end - -mxsz = max(sz(1),sz(2)); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('ampl') ~= 1) - ampl = 1; -end - -if (exist('ph') ~= 1) - ph = 0; -end - -%------------------------------------------------------------ - -res = ampl * cos( (pi/mxsz) * mkR(sz,2) + ph ); - diff --git a/evaluation/utils/matlabPyrTools/modulateFlip.m b/evaluation/utils/matlabPyrTools/modulateFlip.m deleted file mode 100755 index eb27303..0000000 --- a/evaluation/utils/matlabPyrTools/modulateFlip.m +++ /dev/null @@ -1,19 +0,0 @@ -% [HFILT] = modulateFlipShift(LFILT) -% -% QMF/Wavelet highpass filter construction: modulate by (-1)^n, -% reverse order (and shift by one, which is handled by the convolution -% routines). This is an extension of the original definition of QMF's -% (e.g., see Simoncelli90). - -% Eero Simoncelli, 7/96. - -function [hfilt] = modulateFlipShift(lfilt) - -lfilt = lfilt(:); - -sz = size(lfilt,1); -sz2 = ceil(sz/2); - -ind = [sz:-1:1]'; - -hfilt = lfilt(ind) .* (-1).^(ind-sz2); diff --git a/evaluation/utils/matlabPyrTools/namedFilter.m b/evaluation/utils/matlabPyrTools/namedFilter.m deleted file mode 100755 index 0689dbc..0000000 --- a/evaluation/utils/matlabPyrTools/namedFilter.m +++ /dev/null @@ -1,71 +0,0 @@ -% KERNEL = NAMED_FILTER(NAME) -% -% Some standard 1D filter kernels. These are scaled such that -% their L2-norm is 1.0. -% -% binomN - binomial coefficient filter of order N-1 -% haar: - Haar wavelet. -% qmf8, qmf12, qmf16 - Symmetric Quadrature Mirror Filters [Johnston80] -% daub2,daub3,daub4 - Daubechies wavelet [Daubechies88]. -% qmf5, qmf9, qmf13: - Symmetric Quadrature Mirror Filters [Simoncelli88,Simoncelli90] -% -% See bottom of file for full citations. - -% Eero Simoncelli, 6/96. - -function [kernel] = named_filter(name) - -if strcmp(name(1:min(5,size(name,2))), 'binom') - kernel = sqrt(2) * binomialFilter(str2num(name(6:size(name,2)))); -elseif strcmp(name,'qmf5') - kernel = [-0.076103 0.3535534 0.8593118 0.3535534 -0.076103]'; -elseif strcmp(name,'qmf9') - kernel = [0.02807382 -0.060944743 -0.073386624 0.41472545 0.7973934 ... - 0.41472545 -0.073386624 -0.060944743 0.02807382]'; -elseif strcmp(name,'qmf13') - kernel = [-0.014556438 0.021651438 0.039045125 -0.09800052 ... - -0.057827797 0.42995453 0.7737113 0.42995453 -0.057827797 ... - -0.09800052 0.039045125 0.021651438 -0.014556438]'; -elseif strcmp(name,'qmf8') - kernel = sqrt(2) * [0.00938715 -0.07065183 0.06942827 0.4899808 ... - 0.4899808 0.06942827 -0.07065183 0.00938715 ]'; -elseif strcmp(name,'qmf12') - kernel = sqrt(2) * [-0.003809699 0.01885659 -0.002710326 -0.08469594 ... - 0.08846992 0.4843894 0.4843894 0.08846992 -0.08469594 -0.002710326 ... - 0.01885659 -0.003809699 ]'; -elseif strcmp(name,'qmf16') - kernel = sqrt(2) * [0.001050167 -0.005054526 -0.002589756 0.0276414 -0.009666376 ... - -0.09039223 0.09779817 0.4810284 0.4810284 0.09779817 -0.09039223 -0.009666376 ... - 0.0276414 -0.002589756 -0.005054526 0.001050167 ]'; -elseif strcmp(name,'haar') - kernel = [1 1]' / sqrt(2); -elseif strcmp(name,'daub2') - kernel = [0.482962913145 0.836516303738 0.224143868042 -0.129409522551]'; -elseif strcmp(name,'daub3') - kernel = [0.332670552950 0.806891509311 0.459877502118 -0.135011020010 ... - -0.085441273882 0.035226291882]'; -elseif strcmp(name,'daub4') - kernel = [0.230377813309 0.714846570553 0.630880767930 -0.027983769417 ... - -0.187034811719 0.030841381836 0.032883011667 -0.010597401785]'; -elseif strcmp(name,'gauss5') % for backward-compatibility - kernel = sqrt(2) * [0.0625 0.25 0.375 0.25 0.0625]'; -elseif strcmp(name,'gauss3') % for backward-compatibility - kernel = sqrt(2) * [0.25 0.5 0.25]'; -else - error(sprintf('Bad filter name: %s\n',name)); -end - -% [Johnston80] - J D Johnston, "A filter family designed for use in quadrature -% mirror filter banks", Proc. ICASSP, pp 291-294, 1980. -% -% [Daubechies88] - I Daubechies, "Orthonormal bases of compactly supported wavelets", -% Commun. Pure Appl. Math, vol. 42, pp 909-996, 1988. -% -% [Simoncelli88] - E P Simoncelli, "Orthogonal sub-band image transforms", -% PhD Thesis, MIT Dept. of Elec. Eng. and Comp. Sci. May 1988. -% Also available as: MIT Media Laboratory Vision and Modeling Technical -% Report #100. -% -% [Simoncelli90] - E P Simoncelli and E H Adelson, "Subband image coding", -% Subband Transforms, chapter 4, ed. John W Woods, Kluwer Academic -% Publishers, Norwell, MA, 1990, pp 143--192. diff --git a/evaluation/utils/matlabPyrTools/nextFig.m b/evaluation/utils/matlabPyrTools/nextFig.m deleted file mode 100755 index e0ac73f..0000000 --- a/evaluation/utils/matlabPyrTools/nextFig.m +++ /dev/null @@ -1,19 +0,0 @@ -% nextFig (MAXFIGS, SKIP) -% -% Make figure number mod((GCF+SKIP), MAXFIGS) the current figure. -% MAXFIGS is optional, and defaults to 2. -% SKIP is optional, and defaults to 1. - -% Eero Simoncelli, 2/97. - -function nextFig(maxfigs, skip) - -if (exist('maxfigs') ~= 1) - maxfigs = 2; -end - -if (exist('skip') ~= 1) - skip = 1; -end - -figure(1+mod(gcf-1+skip,maxfigs)); diff --git a/evaluation/utils/matlabPyrTools/pgmRead.m b/evaluation/utils/matlabPyrTools/pgmRead.m deleted file mode 100755 index 86c3b62..0000000 --- a/evaluation/utils/matlabPyrTools/pgmRead.m +++ /dev/null @@ -1,59 +0,0 @@ -% IM = pgmRead( FILENAME ) -% -% Load a pgm image into a MatLab matrix. -% This format is accessible from the XV image browsing utility. -% Only works for 8bit gray images (raw or ascii) - -% Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. - -function im = pgmRead( fname ); - -[fid,msg] = fopen( fname, 'r' ); - -if (fid == -1) - error(msg); -end - -%%% First line contains ID string: -%%% "P1" = ascii bitmap, "P2" = ascii greymap, -%%% "P3" = ascii pixmap, "P4" = raw bitmap, -%%% "P5" = raw greymap, "P6" = raw pixmap -TheLine = fgetl(fid); -format = TheLine; - -if ~((format(1:2) == 'P2') | (format(1:2) == 'P5')) - error('PGM file must be of type P2 or P5'); -end - -%%% Any number of comment lines -TheLine = fgetl(fid); -while TheLine(1) == '#' - TheLine = fgetl(fid); -end - -%%% dimensions -sz = sscanf(TheLine,'%d',2); -xdim = sz(1); -ydim = sz(2); -sz = xdim * ydim; - -%%% Maximum pixel value -TheLine = fgetl(fid); -maxval = sscanf(TheLine, '%d',1); - -%%im = zeros(dim,1); -if (format(2) == '2') - [im,count] = fscanf(fid,'%d',sz); -else - [im,count] = fread(fid,sz,'uchar'); -end - -fclose(fid); - -if (count == sz) - im = reshape( im, xdim, ydim )'; -else - fprintf(1,'Warning: File ended early!'); - im = reshape( [im ; zeros(sz-count,1)], xdim, ydim)'; -end - diff --git a/evaluation/utils/matlabPyrTools/pgmWrite.m b/evaluation/utils/matlabPyrTools/pgmWrite.m deleted file mode 100755 index 09c14c9..0000000 --- a/evaluation/utils/matlabPyrTools/pgmWrite.m +++ /dev/null @@ -1,120 +0,0 @@ -% RANGE = pgmWrite(MTX, FILENAME, RANGE, TYPE, COMMENT) -% -% Write a MatLab matrix to a pgm (graylevel image) file. -% This format is accessible from the XV image browsing utility. -% -% RANGE (optional) is a 2-vector specifying the values that map to -% black and white, respectively. Passing a value of 'auto' (default) -% sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets -% RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets -% RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile -% value of the sorted MATRIX samples, and p2 is the 90th percentile -% value. -% -% TYPE (optional) should be 'raw' or 'ascii'. Defaults to 'raw'. - -% Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. - -function range = pgmWrite(mtx, fname, range, type, comment ); - -[fid,msg] = fopen( fname, 'w' ); - -if (fid == -1) - error(msg); -end - -%------------------------------------------------------------ -%% optional ARGS: - -if (exist('range') ~= 1) - range = 'auto'; -end - -if (exist('type') ~= 1) - type = 'raw'; -end -%------------------------------------------------------------ - -%% Automatic range calculation: -if (strcmp(range,'auto1') | strcmp(range,'auto')) - [mn,mx] = range2(mtx); - range = [mn,mx]; - -elseif strcmp(range,'auto2') - stdev = sqrt(var2(mtx)); - av = mean2(mtx); - range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs - -elseif strcmp(range, 'auto3') - percentile = 0.1; % MAGIC NUMBER: 0 size(pind,1)) | (band < 1)) - error(sprintf('BAND_NUM must be between 1 and number of pyramid bands (%d).', ... - size(pind,1))); -end - -if (size(pind,2) ~= 2) - error('INDICES must be an Nx2 matrix indicating the size of the pyramid subbands'); -end - -ind = 1; -for l=1:band-1 - ind = ind + prod(pind(l,:)); -end - -indices = ind:ind+prod(pind(band,:))-1; diff --git a/evaluation/utils/matlabPyrTools/pyrLow.m b/evaluation/utils/matlabPyrTools/pyrLow.m deleted file mode 100755 index 290e806..0000000 --- a/evaluation/utils/matlabPyrTools/pyrLow.m +++ /dev/null @@ -1,12 +0,0 @@ -% RES = pyrLow(PYR, INDICES) -% -% Access the lowpass subband from a pyramid -% (gaussian, laplacian, QMF/wavelet, steerable). - -% Eero Simoncelli, 6/96. - -function res = pyrLow(pyr,pind) - -band = size(pind,1); - -res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); diff --git a/evaluation/utils/matlabPyrTools/pyrTools.pdf b/evaluation/utils/matlabPyrTools/pyrTools.pdf deleted file mode 100755 index 71c42ba..0000000 Binary files a/evaluation/utils/matlabPyrTools/pyrTools.pdf and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/range2.m b/evaluation/utils/matlabPyrTools/range2.m deleted file mode 100755 index 1709a0e..0000000 --- a/evaluation/utils/matlabPyrTools/range2.m +++ /dev/null @@ -1,18 +0,0 @@ -% [MIN, MAX] = range2(MTX) -% -% Compute minimum and maximum values of MTX, returning them as a 2-vector. - -% Eero Simoncelli, 3/97. - -function [mn, mx] = range2(mtx) - -%% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) - -fprintf(1,'WARNING: You should compile the MEX version of "range2.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); - -if (~isreal(mtx)) - error('MTX must be real-valued'); -end - -mn = min(min(mtx)); -mx = max(max(mtx)); diff --git a/evaluation/utils/matlabPyrTools/range2.mexa64 b/evaluation/utils/matlabPyrTools/range2.mexa64 deleted file mode 100755 index a6d7c19..0000000 Binary files a/evaluation/utils/matlabPyrTools/range2.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/range2.mexglx b/evaluation/utils/matlabPyrTools/range2.mexglx deleted file mode 100755 index 7053170..0000000 Binary files a/evaluation/utils/matlabPyrTools/range2.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/range2.mexmac b/evaluation/utils/matlabPyrTools/range2.mexmac deleted file mode 100755 index 8f32249..0000000 Binary files a/evaluation/utils/matlabPyrTools/range2.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/range2.mexw32 b/evaluation/utils/matlabPyrTools/range2.mexw32 deleted file mode 100755 index 513b195..0000000 Binary files a/evaluation/utils/matlabPyrTools/range2.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/rconv2.m b/evaluation/utils/matlabPyrTools/rconv2.m deleted file mode 100755 index 0c12490..0000000 --- a/evaluation/utils/matlabPyrTools/rconv2.m +++ /dev/null @@ -1,50 +0,0 @@ -% RES = RCONV2(MTX1, MTX2, CTR) -% -% Convolution of two matrices, with boundaries handled via reflection -% about the edge pixels. Result will be of size of LARGER matrix. -% -% The origin of the smaller matrix is assumed to be its center. -% For even dimensions, the origin is determined by the CTR (optional) -% argument: -% CTR origin -% 0 DIM/2 (default) -% 1 (DIM/2)+1 - -% Eero Simoncelli, 6/96. - -function c = rconv2(a,b,ctr) - -if (exist('ctr') ~= 1) - ctr = 0; -end - -if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) - large = a; small = b; -elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) - large = b; small = a; -else - error('one arg must be larger than the other in both dimensions!'); -end - -ly = size(large,1); -lx = size(large,2); -sy = size(small,1); -sx = size(small,2); - -%% These values are one less than the index of the small mtx that falls on -%% the border pixel of the large matrix when computing the first -%% convolution response sample: -sy2 = floor((sy+ctr-1)/2); -sx2 = floor((sx+ctr-1)/2); - -% pad with reflected copies -clarge = [ - large(sy-sy2:-1:2,sx-sx2:-1:2), large(sy-sy2:-1:2,:), ... - large(sy-sy2:-1:2,lx-1:-1:lx-sx2); ... - large(:,sx-sx2:-1:2), large, large(:,lx-1:-1:lx-sx2); ... - large(ly-1:-1:ly-sy2,sx-sx2:-1:2), ... - large(ly-1:-1:ly-sy2,:), ... - large(ly-1:-1:ly-sy2,lx-1:-1:lx-sx2) ]; - -c = conv2(clarge,small,'valid'); - diff --git a/evaluation/utils/matlabPyrTools/rcosFn.m b/evaluation/utils/matlabPyrTools/rcosFn.m deleted file mode 100755 index 5dac344..0000000 --- a/evaluation/utils/matlabPyrTools/rcosFn.m +++ /dev/null @@ -1,45 +0,0 @@ -% [X, Y] = rcosFn(WIDTH, POSITION, VALUES) -% -% Return a lookup table (suitable for use by INTERP1) -% containing a "raised cosine" soft threshold function: -% -% Y = VALUES(1) + (VALUES(2)-VALUES(1)) * -% cos^2( PI/2 * (X - POSITION + WIDTH)/WIDTH ) -% -% WIDTH is the width of the region over which the transition occurs -% (default = 1). POSITION is the location of the center of the -% threshold (default = 0). VALUES (default = [0,1]) specifies the -% values to the left and right of the transition. - -% Eero Simoncelli, 7/96. - -function [X, Y] = rcosFn(width,position,values) - -%------------------------------------------------------------ -% OPTIONAL ARGS: - -if (exist('width') ~= 1) - width = 1; -end - -if (exist('position') ~= 1) - position = 0; -end - -if (exist('values') ~= 1) - values = [0,1]; -end - -%------------------------------------------------------------ - -sz = 256; %% arbitrary! - -X = pi * [-sz-1:1] / (2*sz); - -Y = values(1) + (values(2)-values(1)) * cos(X).^2; - -% Make sure end values are repeated, for extrapolation... -Y(1) = Y(2); -Y(sz+3) = Y(sz+2); - -X = position + (2*width/pi) * (X + pi/4); diff --git a/evaluation/utils/matlabPyrTools/reconLpyr.m b/evaluation/utils/matlabPyrTools/reconLpyr.m deleted file mode 100755 index cddcc12..0000000 --- a/evaluation/utils/matlabPyrTools/reconLpyr.m +++ /dev/null @@ -1,83 +0,0 @@ -% RES = reconLpyr(PYR, INDICES, LEVS, FILT2, EDGES) -% -% Reconstruct image from Laplacian pyramid, as created by buildLpyr. -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. -% -% LEVS (optional) should be a list of levels to include, or the string -% 'all' (default). The finest scale is number 1. The lowpass band -% corresponds to lpyrHt(INDICES)+1. -% -% FILT2 (optional) can be a string naming a standard filter (see -% namedFilter), or a vector which will be used for (separable) -% convolution. Default = 'binom5'. EDGES specifies edge-handling, -% and defaults to 'reflect1' (see corrDn). - -% Eero Simoncelli, 6/96 - -function res = reconLpyr(pyr, ind, levs, filt2, edges) - -if (nargin < 2) - error('First two arguments (PYR, INDICES) are required'); -end - -%%------------------------------------------------------------ -%% DEFAULTS: - -if (exist('levs') ~= 1) - levs = 'all'; -end - -if (exist('filt2') ~= 1) - filt2 = 'binom5'; -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end -%%------------------------------------------------------------ - -maxLev = 1+lpyrHt(ind); -if strcmp(levs,'all') - levs = [1:maxLev]'; -else - if (any(levs > maxLev)) - error(sprintf('Level numbers must be in the range [1, %d].', maxLev)); - end - levs = levs(:); -end - -if isstr(filt2) - filt2 = namedFilter(filt2); -end - -filt2 = filt2(:); -res_sz = ind(1,:); - -if any(levs > 1) - - int_sz = [ind(1,1), ind(2,2)]; - - nres = reconLpyr( pyr(prod(res_sz)+1:size(pyr,1)), ... - ind(2:size(ind,1),:), levs-1, filt2, edges); - - if (res_sz(1) == 1) - res = upConv(nres, filt2', edges, [1 2], [1 1], res_sz); - elseif (res_sz(2) == 1) - res = upConv(nres, filt2, edges, [2 1], [1 1], res_sz); - else - hi = upConv(nres, filt2, edges, [2 1], [1 1], int_sz); - res = upConv(hi, filt2', edges, [1 2], [1 1], res_sz); - end - -else - - res = zeros(res_sz); - -end - -if any(levs == 1) - res = res + pyrBand(pyr,ind,1); -end diff --git a/evaluation/utils/matlabPyrTools/reconSCFpyr.m b/evaluation/utils/matlabPyrTools/reconSCFpyr.m deleted file mode 100755 index a86f03d..0000000 --- a/evaluation/utils/matlabPyrTools/reconSCFpyr.m +++ /dev/null @@ -1,87 +0,0 @@ -% RES = reconSCFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) -% -% The inverse of buildSCFpyr: Reconstruct image from its complex steerable pyramid representation, -% in the Fourier domain. -% -% The image is reconstructed by forcing the complex subbands to be analytic -% (zero on half of the 2D Fourier plane, as they are supossed to be unless -% they have being modified), and reconstructing from the real part of those -% analytic subbands. That is equivalent to compute the Hilbert transforms of -% the imaginary parts of the subbands, average them with their real -% counterparts, and then reconstructing from the resulting real subbands. -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. -% -% LEVS (optional) should be a list of levels to include, or the string -% 'all' (default). 0 corresonds to the residual highpass subband. -% 1 corresponds to the finest oriented scale. The lowpass band -% corresponds to number spyrHt(INDICES)+1. -% -% BANDS (optional) should be a list of bands to include, or the string -% 'all' (default). 1 = vertical, rest proceeding anti-clockwise. -% -% TWIDTH is the width of the transition region of the radial lowpass -% function, in octaves (default = 1, which gives a raised cosine for -% the bandpass filters). - -% Javier Portilla, 7/04, basing on Eero Simoncelli's Matlab Pyrtools code -% and our common code on texture synthesis (textureSynthesis.m). - -function res = reconSCFpyr(pyr, indices, levs, bands, twidth) - -%%------------------------------------------------------------ -%% DEFAULTS: - -if ~exist('levs'), - levs = 'all'; -end - -if ~exist('bands') - bands = 'all'; -end - -if ~exist('twidth'), - twidth = 1; -elseif (twidth <= 0) - fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); - twidth = 1; -end - -%%------------------------------------------------------------ - - -pind = indices; -Nsc = log2(pind(1,1)/pind(end,1)); -Nor = (size(pind,1)-2)/Nsc; - -for nsc = 1:Nsc, - firstBnum = (nsc-1)*Nor+2; - -%% Re-create analytic subbands - dims = pind(firstBnum,:); - ctr = ceil((dims+0.5)/2); - ang = mkAngle(dims, 0, ctr); - ang(ctr(1),ctr(2)) = -pi/2; - for nor = 1:Nor, - nband = (nsc-1)*Nor+nor+1; - ind = pyrBandIndices(pind,nband); - ch = pyrBand(pyr, pind, nband); - ang0 = pi*(nor-1)/Nor; - xang = mod(ang-ang0+pi, 2*pi) - pi; - amask = 2*(abs(xang) < pi/2) + (abs(xang) == pi/2); - amask(ctr(1),ctr(2)) = 1; - amask(:,1) = 1; - amask(1,:) = 1; - amask = fftshift(amask); - ch = ifft2(amask.*fft2(ch)); % "Analytic" version - %f = 1.000008; % With this factor the reconstruction SNR goes up around 6 dB! - f = 1; - ch = f*0.5*real(ch); % real part - pyr(ind) = ch; - end % nor -end % nsc - -res = reconSFpyr(pyr, indices, levs, bands, twidth); - diff --git a/evaluation/utils/matlabPyrTools/reconSFpyr.m b/evaluation/utils/matlabPyrTools/reconSFpyr.m deleted file mode 100755 index 0e3109e..0000000 --- a/evaluation/utils/matlabPyrTools/reconSFpyr.m +++ /dev/null @@ -1,108 +0,0 @@ -% RES = reconSFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) -% -% Reconstruct image from its steerable pyramid representation, in the Fourier -% domain, as created by buildSFpyr. -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. -% -% LEVS (optional) should be a list of levels to include, or the string -% 'all' (default). 0 corresonds to the residual highpass subband. -% 1 corresponds to the finest oriented scale. The lowpass band -% corresponds to number spyrHt(INDICES)+1. -% -% BANDS (optional) should be a list of bands to include, or the string -% 'all' (default). 1 = vertical, rest proceeding anti-clockwise. -% -% TWIDTH is the width of the transition region of the radial lowpass -% function, in octaves (default = 1, which gives a raised cosine for -% the bandpass filters). - -%%% MODIFIED VERSION, 7/04, uses different lookup table for radial frequency! - -% Eero Simoncelli, 5/97. - -function res = reconSFpyr(pyr, pind, levs, bands, twidth) - -%%------------------------------------------------------------ -%% DEFAULTS: - -if (exist('levs') ~= 1) - levs = 'all'; -end - -if (exist('bands') ~= 1) - bands = 'all'; -end - -if (exist('twidth') ~= 1) - twidth = 1; -elseif (twidth <= 0) - fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); - twidth = 1; -end - -%%------------------------------------------------------------ - -nbands = spyrNumBands(pind); - -maxLev = 1+spyrHt(pind); -if strcmp(levs,'all') - levs = [0:maxLev]'; -else - if (any(levs > maxLev) | any(levs < 0)) - error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); - end - levs = levs(:); -end - -if strcmp(bands,'all') - bands = [1:nbands]'; -else - if (any(bands < 1) | any(bands > nbands)) - error(sprintf('Band numbers must be in the range [1,3].', nbands)); - end - bands = bands(:); -end - -%---------------------------------------------------------------------- - -dims = pind(1,:); -ctr = ceil((dims+0.5)/2); - -[xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... - ([1:dims(1)]-ctr(1))./(dims(1)/2) ); -angle = atan2(yramp,xramp); -log_rad = sqrt(xramp.^2 + yramp.^2); -log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); -log_rad = log2(log_rad); - -%% Radial transition function (a raised cosine in log-frequency): -[Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); -Yrcos = sqrt(Yrcos); -YIrcos = sqrt(abs(1.0 - Yrcos.^2)); - -if (size(pind,1) == 2) - if (any(levs==1)) - resdft = fftshift(fft2(pyrBand(pyr,pind,2))); - else - resdft = zeros(pind(2,:)); - end -else - resdft = reconSFpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... - pind(2:size(pind,1),:), ... - log_rad, Xrcos, Yrcos, angle, nbands, levs, bands); -end - -lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); -resdft = resdft .* lo0mask; - -%% residual highpass subband -if any(levs == 0) - hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); - hidft = fftshift(fft2(subMtx(pyr, pind(1,:)))); - resdft = resdft + hidft .* hi0mask; -end - -res = real(ifft2(ifftshift(resdft))); diff --git a/evaluation/utils/matlabPyrTools/reconSFpyrLevs.m b/evaluation/utils/matlabPyrTools/reconSFpyrLevs.m deleted file mode 100755 index 420f278..0000000 --- a/evaluation/utils/matlabPyrTools/reconSFpyrLevs.m +++ /dev/null @@ -1,69 +0,0 @@ -% RESDFT = reconSFpyrLevs(PYR,INDICES,LOGRAD,XRCOS,YRCOS,ANGLE,NBANDS,LEVS,BANDS) -% -% Recursive function for reconstructing levels of a steerable pyramid -% representation. This is called by reconSFpyr, and is not usually -% called directly. - -% Eero Simoncelli, 5/97. - -function resdft = reconSFpyrLevs(pyr,pind,log_rad,Xrcos,Yrcos,angle,nbands,levs,bands); - -lo_ind = nbands+1; -dims = pind(1,:); -ctr = ceil((dims+0.5)/2); - -% log_rad = log_rad + 1; -Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. - -if any(levs > 1) - - lodims = ceil((dims-0.5)/2); - loctr = ceil((lodims+0.5)/2); - lostart = ctr-loctr+1; - loend = lostart+lodims-1; - nlog_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); - nangle = angle(lostart(1):loend(1),lostart(2):loend(2)); - - if (size(pind,1) > lo_ind) - nresdft = reconSFpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)),... - pind(lo_ind:size(pind,1),:), ... - nlog_rad, Xrcos, Yrcos, nangle, nbands,levs-1, bands); - else - nresdft = fftshift(fft2(pyrBand(pyr,pind,lo_ind))); - end - - YIrcos = sqrt(abs(1.0 - Yrcos.^2)); - lomask = pointOp(nlog_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); - - resdft = zeros(dims); - resdft(lostart(1):loend(1),lostart(2):loend(2)) = nresdft .* lomask; - -else - - resdft = zeros(dims); - -end - - -if any(levs == 1) - - lutsize = 1024; - Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] - order = nbands-1; - %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) - const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); - Ycosn = sqrt(const) * (cos(Xcosn)).^order; - himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1),0); - - ind = 1; - for b = 1:nbands - if any(bands == b) - anglemask = pointOp(angle,Ycosn,Xcosn(1)+pi*(b-1)/nbands,Xcosn(2)-Xcosn(1)); - band = reshape(pyr(ind:ind+prod(dims)-1), dims(1), dims(2)); - banddft = fftshift(fft2(band)); - resdft = resdft + (sqrt(-1))^(nbands-1) * banddft.*anglemask.*himask; - end - ind = ind + prod(dims); - end -end - diff --git a/evaluation/utils/matlabPyrTools/reconSpyr.m b/evaluation/utils/matlabPyrTools/reconSpyr.m deleted file mode 100755 index fc9317f..0000000 --- a/evaluation/utils/matlabPyrTools/reconSpyr.m +++ /dev/null @@ -1,96 +0,0 @@ -% RES = reconSpyr(PYR, INDICES, FILTFILE, EDGES, LEVS, BANDS) -% -% Reconstruct image from its steerable pyramid representation, as created -% by buildSpyr. -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. -% -% FILTFILE (optional) should be a string referring to an m-file that returns -% the rfilters. examples: sp0Filters, sp1Filters, sp3Filters -% (default = 'sp1Filters'). -% EDGES specifies edge-handling, and defaults to 'reflect1' (see -% corrDn). -% -% LEVS (optional) should be a list of levels to include, or the string -% 'all' (default). 0 corresonds to the residual highpass subband. -% 1 corresponds to the finest oriented scale. The lowpass band -% corresponds to number spyrHt(INDICES)+1. -% -% BANDS (optional) should be a list of bands to include, or the string -% 'all' (default). 1 = vertical, rest proceeding anti-clockwise. - -% Eero Simoncelli, 6/96. - -function res = reconSpyr(pyr, pind, filtfile, edges, levs, bands) - -%%------------------------------------------------------------ -%% DEFAULTS: - -if (exist('filtfile') ~= 1) - filtfile = 'sp1Filters'; -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end - -if (exist('levs') ~= 1) - levs = 'all'; -end - -if (exist('bands') ~= 1) - bands = 'all'; -end - -%%------------------------------------------------------------ - -if (isstr(filtfile) & (exist(filtfile) == 2)) - [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); - nbands = spyrNumBands(pind); - if ((nbands > 0) & (size(bfilts,2) ~= nbands)) - error('Number of pyramid bands is inconsistent with filter file'); - end -else - error('filtfile argument must be the name of an M-file containing SPYR filters.'); -end - -maxLev = 1+spyrHt(pind); -if strcmp(levs,'all') - levs = [0:maxLev]'; -else - if (any(levs > maxLev) | any(levs < 0)) - error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); - end - levs = levs(:); -end - -if strcmp(bands,'all') - bands = [1:nbands]'; -else - if (any(bands < 1) | any(bands > nbands)) - error(sprintf('Band numbers must be in the range [1,3].', nbands)); - end - bands = bands(:); -end - -if (spyrHt(pind) == 0) - if (any(levs==1)) - res1 = pyrBand(pyr,pind,2); - else - res1 = zeros(pind(2,:)); - end -else - res1 = reconSpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... - pind(2:size(pind,1),:), ... - lofilt, bfilts, edges, levs, bands); -end - -res = upConv(res1, lo0filt, edges); - -%% residual highpass subband -if any(levs == 0) - res = upConv( subMtx(pyr, pind(1,:)), hi0filt, edges, [1 1], [1 1], size(res), res); -end - diff --git a/evaluation/utils/matlabPyrTools/reconSpyrLevs.m b/evaluation/utils/matlabPyrTools/reconSpyrLevs.m deleted file mode 100755 index e8db963..0000000 --- a/evaluation/utils/matlabPyrTools/reconSpyrLevs.m +++ /dev/null @@ -1,46 +0,0 @@ -% RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS) -% -% Recursive function for reconstructing levels of a steerable pyramid -% representation. This is called by reconSpyr, and is not usually -% called directly. - -% Eero Simoncelli, 6/96. - -function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands); - -nbands = size(bfilts,2); -lo_ind = nbands+1; -res_sz = pind(1,:); - -% Assume square filters: -bfiltsz = round(sqrt(size(bfilts,1))); - -if any(levs > 1) - - if (size(pind,1) > lo_ind) - nres = reconSpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)), ... - pind(lo_ind:size(pind,1),:), ... - lofilt, bfilts, edges, levs-1, bands); - else - nres = pyrBand(pyr,pind,lo_ind); % lowpass subband - end - - res = upConv(nres, lofilt, edges, [2 2], [1 1], res_sz); - -else - - res = zeros(res_sz); - -end - -if any(levs == 1) - ind = 1; - for b = 1:nbands - if any(bands == b) - bfilt = reshape(bfilts(:,b), bfiltsz, bfiltsz); - res = upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ... - bfilt, edges, [1 1], [1 1], res_sz, res); - end - ind = ind + prod(res_sz); - end -end diff --git a/evaluation/utils/matlabPyrTools/reconWpyr.m b/evaluation/utils/matlabPyrTools/reconWpyr.m deleted file mode 100755 index fc31226..0000000 --- a/evaluation/utils/matlabPyrTools/reconWpyr.m +++ /dev/null @@ -1,148 +0,0 @@ -% RES = reconWpyr(PYR, INDICES, FILT, EDGES, LEVS, BANDS) -% -% Reconstruct image from its separable orthonormal QMF/wavelet pyramid -% representation, as created by buildWpyr. -% -% PYR is a vector containing the N pyramid subbands, ordered from fine -% to coarse. INDICES is an Nx2 matrix containing the sizes of -% each subband. This is compatible with the MatLab Wavelet toolbox. -% -% FILT (optional) can be a string naming a standard filter (see -% namedFilter), or a vector which will be used for (separable) -% convolution. Default = 'qmf9'. EDGES specifies edge-handling, -% and defaults to 'reflect1' (see corrDn). -% -% LEVS (optional) should be a vector of levels to include, or the string -% 'all' (default). 1 corresponds to the finest scale. The lowpass band -% corresponds to wpyrHt(INDICES)+1. -% -% BANDS (optional) should be a vector of bands to include, or the string -% 'all' (default). 1=horizontal, 2=vertical, 3=diagonal. This is only used -% for pyramids of 2D images. - -% Eero Simoncelli, 6/96. - -function res = reconWpyr(pyr, ind, filt, edges, levs, bands) - -if (nargin < 2) - error('First two arguments (PYR INDICES) are required'); -end - -%%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('filt') ~= 1) - filt = 'qmf9'; -end - -if (exist('edges') ~= 1) - edges= 'reflect1'; -end - -if (exist('levs') ~= 1) - levs = 'all'; -end - -if (exist('bands') ~= 1) - bands = 'all'; -end - -%%------------------------------------------------------------ - -maxLev = 1+wpyrHt(ind); -if strcmp(levs,'all') - levs = [1:maxLev]'; -else - if (any(levs > maxLev)) - error(sprintf('Level numbers must be in the range [1, %d].', maxLev)); - end - levs = levs(:); -end - -if strcmp(bands,'all') - bands = [1:3]'; -else - if (any(bands < 1) | any(bands > 3)) - error('Band numbers must be in the range [1,3].'); - end - bands = bands(:); -end - -if isstr(filt) - filt = namedFilter(filt); -end - -filt = filt(:); -hfilt = modulateFlip(filt); - -%% For odd-length filters, stagger the sampling lattices: -if (mod(size(filt,1),2) == 0) - stag = 2; -else - stag = 1; -end - -%% Compute size of result image: assumes critical sampling (boundaries correct) -res_sz = ind(1,:); -if (res_sz(1) == 1) - loind = 2; - res_sz(2) = sum(ind(:,2)); -elseif (res_sz(2) == 1) - loind = 2; - res_sz(1) = sum(ind(:,1)); -else - loind = 4; - res_sz = ind(1,:) + ind(2,:); %%horizontal + vertical bands. - hres_sz = [ind(1,1), res_sz(2)]; - lres_sz = [ind(2,1), res_sz(2)]; -end - - -%% First, recursively collapse coarser scales: -if any(levs > 1) - - if (size(ind,1) > loind) - nres = reconWpyr( pyr(1+sum(prod(ind(1:loind-1,:)')):size(pyr,1)), ... - ind(loind:size(ind,1),:), filt, edges, levs-1, bands); - else - nres = pyrBand(pyr, ind, loind); % lowpass subband - end - - if (res_sz(1) == 1) - res = upConv(nres, filt', edges, [1 2], [1 stag], res_sz); - elseif (res_sz(2) == 1) - res = upConv(nres, filt, edges, [2 1], [stag 1], res_sz); - else - ires = upConv(nres, filt', edges, [1 2], [1 stag], lres_sz); - res = upConv(ires, filt, edges, [2 1], [stag 1], res_sz); - end - -else - - res = zeros(res_sz); - -end - - -%% Add in reconstructed bands from this level: -if any(levs == 1) - if (res_sz(1) == 1) - upConv(pyrBand(pyr,ind,1), hfilt', edges, [1 2], [1 2], res_sz, res); - elseif (res_sz(2) == 1) - upConv(pyrBand(pyr,ind,1), hfilt, edges, [2 1], [2 1], res_sz, res); - else - if any(bands == 1) % horizontal - ires = upConv(pyrBand(pyr,ind,1),filt',edges,[1 2],[1 stag],hres_sz); - upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res - end - if any(bands == 2) % vertical - ires = upConv(pyrBand(pyr,ind,2),hfilt',edges,[1 2],[1 2],lres_sz); - upConv(ires,filt,edges,[2 1],[stag 1],res_sz,res); %destructively modify res - end - if any(bands == 3) % diagonal - ires = upConv(pyrBand(pyr,ind,3),hfilt',edges,[1 2],[1 2],hres_sz); - upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res - end - end -end - diff --git a/evaluation/utils/matlabPyrTools/setPyrBand.m b/evaluation/utils/matlabPyrTools/setPyrBand.m deleted file mode 100755 index 099022d..0000000 --- a/evaluation/utils/matlabPyrTools/setPyrBand.m +++ /dev/null @@ -1,32 +0,0 @@ -% NEWPYR = setPyrBand(PYR, INDICES, NEWBAND, BAND_NUM) -% -% Insert an image (BAND) into a pyramid (gaussian, laplacian, QMF/wavelet, -% or steerable). Subbands are numbered consecutively, from finest -% (highest spatial frequency) to coarsest (lowest spatial frequency). - -% Eero Simoncelli, 1/03. - -function pyr = setPyrBand(pyr, pind, band, bandNum) - -%% Check: PIND a valid index matrix? -if ( ~(ndims(pind) == 2) | ~(size(pind,2) == 2) | ~all(pind==round(pind)) ) - pind - error('pyrTools:badArg',... - 'PIND argument is not an Nbands X 2 matrix of integers'); -end - -%% Check: PIND consistent with size of PYR? -if ( length(pyr) ~= sum(prod(pind,2)) ) - error('pyrTools:badPyr',... - 'Pyramid data vector length is inconsistent with index matrix PIND'); -end - -%% Check: size of BAND consistent with desired BANDNUM? -if (~all(size(band) == pind(bandNum,:))) - size(band) - pind(bandNum,:) - error('pyrTools:badArg',... - 'size of BAND to be inserted is inconsistent with BAND_NUM'); -end - -pyr(pyrBandIndices(pind,bandNum)) = vectify(band); diff --git a/evaluation/utils/matlabPyrTools/shift.m b/evaluation/utils/matlabPyrTools/shift.m deleted file mode 100755 index 497297e..0000000 --- a/evaluation/utils/matlabPyrTools/shift.m +++ /dev/null @@ -1,15 +0,0 @@ -% [RES] = shift(MTX, OFFSET) -% -% Circular shift 2D matrix samples by OFFSET (a [Y,X] 2-vector), -% such that RES(POS) = MTX(POS-OFFSET). - -function res = shift(mtx, offset) - -dims = size(mtx); - -offset = mod(-offset,dims); - -res = [ mtx(offset(1)+1:dims(1), offset(2)+1:dims(2)), ... - mtx(offset(1)+1:dims(1), 1:offset(2)); ... - mtx(1:offset(1), offset(2)+1:dims(2)), ... - mtx(1:offset(1), 1:offset(2)) ]; diff --git a/evaluation/utils/matlabPyrTools/showIm.m b/evaluation/utils/matlabPyrTools/showIm.m deleted file mode 100755 index a9e2bd1..0000000 --- a/evaluation/utils/matlabPyrTools/showIm.m +++ /dev/null @@ -1,221 +0,0 @@ -% RANGE = showIm (MATRIX, RANGE, ZOOM, LABEL, NSHADES ) -% -% Display a MatLab MATRIX as a grayscale image in the current figure, -% inside the current axes. If MATRIX is complex, the real and imaginary -% parts are shown side-by-side, with the same grayscale mapping. -% -% If MATRIX is a string, it should be the name of a variable bound to a -% MATRIX in the base (global) environment. This matrix is displayed as an -% image, with the title set to the string. -% -% RANGE (optional) is a 2-vector specifying the values that map to -% black and white, respectively. Passing a value of 'auto' (default) -% sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets -% RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets -% RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile -% value of the sorted MATRIX samples, and p2 is the 90th percentile -% value. -% -% ZOOM specifies the number of matrix samples per screen pixel. It -% will be rounded to an integer, or 1 divided by an integer. A value -% of 'same' or 'auto' (default) causes the zoom value to be chosen -% automatically to fit the image into the current axes. A value of -% 'full' fills the axis region (leaving no room for labels). See -% pixelAxes.m. -% -% If LABEL (optional, default = 1, unless zoom='full') is non-zero, the range -% of values that are mapped into the gray colormap and the dimensions -% (size) of the matrix and zoom factor are printed below the image. If label -% is a string, it is used as a title. -% -% NSHADES (optional) specifies the number of gray shades, and defaults -% to the size of the current colormap. - -% Eero Simoncelli, 6/96. - -%%TODO: should use "newplot" - -function range = showIm( im, range, zoom, label, nshades ); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (nargin < 1) - error('Requires at least one input argument.'); -end - -MLv = version; - -if isstr(im) - if (strcmp(MLv(1),'4')) - error('Cannot pass string arg for MATRIX in MatLab version 4.x'); - end - label = im; - im = evalin('base',im); -end - -if (exist('range') ~= 1) - range = 'auto1'; -end - -if (exist('nshades') ~= 1) - nshades = size(colormap,1); -end -nshades = max( nshades, 2 ); - -if (exist('zoom') ~= 1) - zoom = 'auto'; -end - -if (exist('label') ~= 1) - if strcmp(zoom,'full') - label = 0; % no labeling - else - label = 1; % just print grayrange & dims - end -end - -%------------------------------------------------------------ - -%% Automatic range calculation: -if (strcmp(range,'auto1') | strcmp(range,'auto')) - if isreal(im) - [mn,mx] = range2(im); - else - [mn1,mx1] = range2(real(im)); - [mn2,mx2] = range2(imag(im)); - mn = min(mn1,mn2); - mx = max(mx1,mx2); - end - if any(size(im)==1) - pad = (mx-mn)/12; % MAGIC NUMBER: graph padding - range = [mn-pad, mx+pad]; - else - range = [mn,mx]; - end - -elseif strcmp(range,'auto2') - if isreal(im) - stdev = sqrt(var2(im)); - av = mean2(im); - else - stdev = sqrt((var2(real(im)) + var2(imag(im)))/2); - av = (mean2(real(im)) + mean2(imag(im)))/2; - end - range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs - -elseif strcmp(range, 'auto3') - percentile = 0.1; % MAGIC NUMBER: 0 1) - zformat = sprintf('* %d',round(zoom)); - else - zformat = sprintf('/ %d',round(1/zoom)); - end - if isreal(im) - format=[' Range: [%.3g, %.3g] \n Dims: [%d, %d] ', zformat]; - else - format=['Range: [%.3g, %.3g] ---- Dims: [%d, %d]', zformat]; - end - xlabel(sprintf(format, range(1), range(2), size(im,1), size(im,2))); - h = get(gca,'Xlabel'); - set(h,'FontSize', 9); % MAGIC NUMBER: font size!!! - - orig_units = get(h,'Units'); - set(h,'Units','points'); - pos = get(h,'Position'); - pos(1:2) = pos(1:2) + [xlbl_offset, 10]; % MAGIC NUMBER: y offset in points - set(h,'Position',pos); - set(h,'Units',orig_units); - - set(h,'Visible','on'); % axis('image') turned the xlabel off... - end -end - -return; diff --git a/evaluation/utils/matlabPyrTools/showLpyr.m b/evaluation/utils/matlabPyrTools/showLpyr.m deleted file mode 100755 index 0d85f9d..0000000 --- a/evaluation/utils/matlabPyrTools/showLpyr.m +++ /dev/null @@ -1,202 +0,0 @@ -% RANGE = showLpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) -% -% Display a Laplacian (or Gaussian) pyramid, specified by PYR and -% INDICES (see buildLpyr), in the current figure. -% -% RANGE is a 2-vector specifying the values that map to black and -% white, respectively. These values are scaled by -% LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value -% of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' -% sets RANGE to 3 standard deviations below and above 0.0. In both of -% these cases, the lowpass band is independently scaled. A value of -% 'indep1' sets the range of each subband independently, as in a call -% to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband -% to be scaled independently as if by showIm(subband,'indep2'). -% The default value for RANGE is 'auto1' for 1D images, and 'auto2' for -% 2D images. -% -% GAP (optional, default=1) specifies the gap in pixels to leave -% between subbands (2D images only). -% -% LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid -% levels. This should be set to the sum of the kernel taps of the -% lowpass filter used to construct the pyramid (default assumes -% L2-normalalized filters, using a value of 2 for 2D images, sqrt(2) for -% 1D images). - -% Eero Simoncelli, 2/97. - -function [range] = showLpyr(pyr, pind, range, gap, scale); - -% Determine 1D or 2D pyramid: -if ((pind(1,1) == 1) | (pind(1,2) ==1)) - oned = 1; -else - oned = 0; -end - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('range') ~= 1) - if (oned==1) - range = 'auto1'; - else - range = 'auto2'; - end -end - -if (exist('gap') ~= 1) - gap = 1; -end - -if (exist('scale') ~= 1) - if (oned == 1) - scale = sqrt(2); - else - scale = 2; - end -end - -%------------------------------------------------------------ - -nind = size(pind,1); - -%% Auto range calculations: -if strcmp(range,'auto1') - range = zeros(nind,1); - mn = 0.0; mx = 0.0; - for bnum = 1:(nind-1) - band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); - range(bnum) = scale^(bnum-1); - [bmn,bmx] = range2(band); - mn = min(mn, bmn); mx = max(mx, bmx); - end - if (oned == 1) - pad = (mx-mn)/12; % *** MAGIC NUMBER!! - mn = mn-pad; mx = mx+pad; - end - range = range * [mn mx]; % outer product - band = pyrLow(pyr,pind); - [mn,mx] = range2(band); - if (oned == 1) - pad = (mx-mn)/12; % *** MAGIC NUMBER!! - mn = mn-pad; mx = mx+pad; - end - range(nind,:) = [mn, mx]; - -elseif strcmp(range,'indep1') - range = zeros(nind,2); - for bnum = 1:nind - band = pyrBand(pyr,pind,bnum); - [mn,mx] = range2(band); - if (oned == 1) - pad = (mx-mn)/12; % *** MAGIC NUMBER!! - mn = mn-pad; mx = mx+pad; - end - range(bnum,:) = [mn mx]; - end - -elseif strcmp(range,'auto2') - range = zeros(nind,1); - sqsum = 0; numpixels = 0; - for bnum = 1:(nind-1) - band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); - sqsum = sqsum + sum(sum(band.^2)); - numpixels = numpixels + prod(size(band)); - range(bnum) = scale^(bnum-1); - end - stdev = sqrt(sqsum/(numpixels-1)); - range = range * [ -3*stdev 3*stdev ]; % outer product - band = pyrLow(pyr,pind); - av = mean2(band); stdev = sqrt(var2(band)); - range(nind,:) = [av-2*stdev,av+2*stdev]; - -elseif strcmp(range,'indep2') - range = zeros(nind,2); - for bnum = 1:(nind-1) - band = pyrBand(pyr,pind,bnum); - stdev = sqrt(var2(band)); - range(bnum,:) = [ -3*stdev 3*stdev ]; - end - band = pyrLow(pyr,pind); - av = mean2(band); stdev = sqrt(var2(band)); - range(nind,:) = [av-2*stdev,av+2*stdev]; - -elseif isstr(range) - error(sprintf('Bad RANGE argument: %s',range)) - -elseif ((size(range,1) == 1) & (size(range,2) == 2)) - scales = scale.^[0:nind-1]; - range = scales(:) * range; % outer product - band = pyrLow(pyr,pind); - range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); - -end - -%% Clear Figure -clf; - -if (oned == 1) - - %%%%% 1D signal: - for bnum=1:nind - band = pyrBand(pyr,pind,bnum); - subplot(nind,1,nind-bnum+1); - plot(band); - axis([1, prod(size(band)), range(bnum,:)]); - end - -else - - %%%%% 2D signal: - colormap(gray); - cmap = get(gcf,'Colormap'); - nshades = size(cmap,1); - - % Find background color index: - clr = get(gcf,'Color'); - bg = 1; - dist = norm(cmap(bg,:)-clr); - for n = 1:nshades - ndist = norm(cmap(n,:)-clr); - if (ndist < dist) - dist = ndist; - bg = n; - end - end - - %% Compute positions of subbands: - llpos = ones(nind,2); - dir = [-1 -1]; - ctr = [pind(1,1)+1+gap 1]; - sz = [0 0]; - for bnum = 1:nind - prevsz = sz; - sz = pind(bnum,:); - - % Determine center position of new band: - ctr = ctr + gap*dir/2 + dir.* floor((prevsz+(dir>0))/2); - dir = dir * [0 -1; 1 0]; % ccw rotation - ctr = ctr + gap*dir/2 + dir.* floor((sz+(dir<0))/2); - llpos(bnum,:) = ctr - floor(sz./2); - end - - %% Make position list positive, and allocate appropriate image: - llpos = llpos - ones(nind,1)*min(llpos) + 1; - urpos = llpos + pind - 1; - d_im = bg + zeros(max(urpos)); - - %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 - for bnum=1:nind - mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); - d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... - mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); - end - - hh = image(d_im); - axis('off'); - pixelAxes(size(d_im),'full'); - set(hh,'UserData',range); - -end diff --git a/evaluation/utils/matlabPyrTools/showSpyr.m b/evaluation/utils/matlabPyrTools/showSpyr.m deleted file mode 100755 index da85715..0000000 --- a/evaluation/utils/matlabPyrTools/showSpyr.m +++ /dev/null @@ -1,188 +0,0 @@ -% RANGE = showSpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) -% -% Display a steerable pyramid, specified by PYR and INDICES -% (see buildSpyr), in the current figure. The highpass band is not shown. -% -% RANGE is a 2-vector specifying the values that map to black and -% white, respectively. These values are scaled by -% LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value -% of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' -% sets RANGE to 3 standard deviations below and above 0.0. In both of -% these cases, the lowpass band is independently scaled. A value of -% 'indep1' sets the range of each subband independently, as in a call -% to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband -% to be scaled independently as if by showIm(subband,'indep2'). -% The default value for RANGE is 'auto2'. -% -% GAP (optional, default=1) specifies the gap in pixels to leave -% between subbands. -% -% LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid -% levels. This should be set to the sum of the kernel taps of the -% lowpass filter used to construct the pyramid (default is 2, which is -% correct for L2-normalized filters. - -% Eero Simoncelli, 2/97. - -function [range] = showSpyr(pyr, pind, range, gap, scale); - -nbands = spyrNumBands(pind); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('range') ~= 1) - range = 'auto2'; -end - -if (exist('gap') ~= 1) - gap = 1; -end - -if (exist('scale') ~= 1) - scale = 2; -end - -%------------------------------------------------------------ - -ht = spyrHt(pind); -nind = size(pind,1); - -%% Auto range calculations: -if strcmp(range,'auto1') - range = ones(nind,1); - band = spyrHigh(pyr,pind); - [mn,mx] = range2(band); - for lnum = 1:ht - for bnum = 1:nbands - band = spyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); - range((lnum-1)*nbands+bnum+1) = scale^(lnum-1); - [bmn,bmx] = range2(band); - mn = min(mn, bmn); - mx = max(mx, bmx); - end - end - range = range * [mn mx]; % outer product - band = pyrLow(pyr,pind); - [mn,mx] = range2(band); - range(nind,:) = [mn, mx]; - -elseif strcmp(range,'indep1') - range = zeros(nind,2); - for bnum = 1:nind - band = pyrBand(pyr,pind,bnum); - [mn,mx] = range2(band); - range(bnum,:) = [mn mx]; - end - -elseif strcmp(range,'auto2') - range = ones(nind,1); - band = spyrHigh(pyr,pind); - sqsum = sum(sum(band.^2)); numpixels = prod(size(band)); - for lnum = 1:ht - for bnum = 1:nbands - band = spyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); - sqsum = sqsum + sum(sum(band.^2)); - numpixels = numpixels + prod(size(band)); - range((lnum-1)*nbands+bnum+1) = scale^(lnum-1); - end - end - stdev = sqrt(sqsum/(numpixels-1)); - range = range * [ -3*stdev 3*stdev ]; % outer product - band = pyrLow(pyr,pind); - av = mean2(band); stdev = sqrt(var2(band)); - range(nind,:) = [av-2*stdev,av+2*stdev]; - -elseif strcmp(range,'indep2') - range = zeros(nind,2); - for bnum = 1:(nind-1) - band = pyrBand(pyr,pind,bnum); - stdev = sqrt(var2(band)); - range(bnum,:) = [ -3*stdev 3*stdev ]; - end - band = pyrLow(pyr,pind); - av = mean2(band); stdev = sqrt(var2(band)); - range(nind,:) = [av-2*stdev,av+2*stdev]; - -elseif isstr(range) - error(sprintf('Bad RANGE argument: %s',range)) - -elseif ((size(range,1) == 1) & (size(range,2) == 2)) - scales = scale.^[0:(ht-1)]; - scales = ones(nbands,1) * scales; %outer product - scales = [1; scales(:); scale^ht]; %tack on highpass and lowpass - range = scales * range; % outer product - band = pyrLow(pyr,pind); - range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); - -end - -% CLEAR FIGURE: -clf; - -colormap(gray); -cmap = get(gcf,'Colormap'); -nshades = size(cmap,1); - -% Find background color index: -clr = get(gcf,'Color'); -bg = 1; -dist = norm(cmap(bg,:)-clr); -for n = 1:nshades - ndist = norm(cmap(n,:)-clr); - if (ndist < dist) - dist = ndist; - bg = n; - end -end - -%% Compute positions of subbands: -llpos = ones(nind,2); - -if (nbands == 2) - ncols = 1; nrows = 2; -else - ncols = ceil((nbands+1)/2); nrows = ceil(nbands/2); -end -relpos = [ (1-nrows):0, zeros(1,(ncols-1)); ... - zeros(1,nrows), -1:-1:(1-ncols) ]'; -if (nbands > 1) - mvpos = [-1 -1]; -else - mvpos = [0 -1]; -end -basepos = [0 0]; - -for lnum = 1:ht - ind1 = (lnum-1)*nbands + 2; - sz = pind(ind1,:)+gap; - basepos = basepos + mvpos .* sz; - if (nbands < 5) % to align edges... - sz = sz + gap*(ht-lnum+1); - end - llpos(ind1:ind1+nbands-1,:) = relpos * diag(sz) + ones(nbands,1)*basepos; -end - -% lowpass band -sz = pind(nind-1,:)+gap; -basepos = basepos + mvpos .* sz; -llpos(nind,:) = basepos; - -%% Make position list positive, and allocate appropriate image: -llpos = llpos - ones(nind,1)*min(llpos) + 1; -llpos(1,:) = [1 1]; -urpos = llpos + pind - 1; -d_im = bg + zeros(max(urpos)); - -%% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 -for bnum=2:nind - mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); - d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... - mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); -end - -hh = image(d_im); -axis('off'); -pixelAxes(size(d_im),'full'); -set(hh,'UserData',range); - diff --git a/evaluation/utils/matlabPyrTools/showWpyr.m b/evaluation/utils/matlabPyrTools/showWpyr.m deleted file mode 100755 index 510e395..0000000 --- a/evaluation/utils/matlabPyrTools/showWpyr.m +++ /dev/null @@ -1,204 +0,0 @@ -% RANGE = showWpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) -% -% Display a separable QMF/wavelet pyramid, specified by PYR and INDICES -% (see buildWpyr), in the current figure. -% -% RANGE is a 2-vector specifying the values that map to black and -% white, respectively. These values are scaled by -% LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value -% of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' -% sets RANGE to 3 standard deviations below and above 0.0. In both of -% these cases, the lowpass band is independently scaled. A value of -% 'indep1' sets the range of each subband independently, as in a call -% to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband -% to be scaled independently as if by showIm(subband,'indep2'). -% The default value for RANGE is 'auto1' for 1D images, and 'auto2' for -% 2D images. -% -% GAP (optional, default=1) specifies the gap in pixels to leave -% between subbands (2D images only). -% -% LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid -% levels. This should be set to the sum of the kernel taps of the -% lowpass filter used to construct the pyramid (default assumes -% L2-normalized filters, using a value of 2 for 2D images, sqrt(2) for -% 1D images). - -% Eero Simoncelli, 2/97. - -function [range] = showWpyr(pyr, pind, range, gap, scale); - -% Determine 1D or 2D pyramid: -if ((pind(1,1) == 1) | (pind(1,2) ==1)) - nbands = 1; -else - nbands = 3; -end - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('range') ~= 1) - if (nbands==1) - range = 'auto1'; - else - range = 'auto2'; - end -end - -if (exist('gap') ~= 1) - gap = 1; -end - -if (exist('scale') ~= 1) - if (nbands == 1) - scale = sqrt(2); - else - scale = 2; - end -end - -%------------------------------------------------------------ - -ht = wpyrHt(pind); -nind = size(pind,1); - -%% Auto range calculations: -if strcmp(range,'auto1') - range = zeros(nind,1); - mn = 0.0; mx = 0.0; - for lnum = 1:ht - for bnum = 1:nbands - band = wpyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); - range((lnum-1)*nbands+bnum) = scale^(lnum-1); - [bmn,bmx] = range2(band); - mn = min(mn, bmn); mx = max(mx, bmx); - end - end - if (nbands == 1) - pad = (mx-mn)/12; % *** MAGIC NUMBER!! - mn = mn-pad; mx = mx+pad; - end - range = range * [mn mx]; % outer product - band = pyrLow(pyr,pind); - [mn,mx] = range2(band); - if (nbands == 1) - pad = (mx-mn)/12; % *** MAGIC NUMBER!! - mn = mn-pad; mx = mx+pad; - end - range(nind,:) = [mn, mx]; - -elseif strcmp(range,'indep1') - range = zeros(nind,2); - for bnum = 1:nind - band = pyrBand(pyr,pind,bnum); - [mn,mx] = range2(band); - if (nbands == 1) - pad = (mx-mn)/12; % *** MAGIC NUMBER!! - mn = mn-pad; mx = mx+pad; - end - range(bnum,:) = [mn mx]; - end - -elseif strcmp(range,'auto2') - range = zeros(nind,1); - sqsum = 0; numpixels = 0; - for lnum = 1:ht - for bnum = 1:nbands - band = wpyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); - sqsum = sqsum + sum(sum(band.^2)); - numpixels = numpixels + prod(size(band)); - range((lnum-1)*nbands+bnum) = scale^(lnum-1); - end - end - stdev = sqrt(sqsum/(numpixels-1)); - range = range * [ -3*stdev 3*stdev ]; % outer product - band = pyrLow(pyr,pind); - av = mean2(band); stdev = sqrt(var2(band)); - range(nind,:) = [av-2*stdev,av+2*stdev]; - -elseif strcmp(range,'indep2') - range = zeros(nind,2); - for bnum = 1:(nind-1) - band = pyrBand(pyr,pind,bnum); - stdev = sqrt(var2(band)); - range(bnum,:) = [ -3*stdev 3*stdev ]; - end - band = pyrLow(pyr,pind); - av = mean2(band); stdev = sqrt(var2(band)); - range(nind,:) = [av-2*stdev,av+2*stdev]; - -elseif isstr(range) - error(sprintf('Bad RANGE argument: %s',range)) - -elseif ((size(range,1) == 1) & (size(range,2) == 2)) - scales = scale.^[0:ht]; - if (nbands ~= 1) - scales = [scales; scales; scales]; - end - range = scales(:) * range; % outer product - band = pyrLow(pyr,pind); - range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); - -end - -% CLEAR FIGURE: -clf; - -if (nbands == 1) - - %%%%% 1D signal: - for bnum=1:nind - band = pyrBand(pyr,pind,bnum); - subplot(nind,1,nind-bnum+1); - plot(band); - axis([1, prod(size(band)), range(bnum,:)]); - end - -else - - %%%%% 2D signal: - colormap(gray); - cmap = get(gcf,'Colormap'); - nshades = size(cmap,1); - - % Find background color index: - clr = get(gcf,'Color'); - bg = 1; - dist = norm(cmap(bg,:)-clr); - for n = 1:nshades - ndist = norm(cmap(n,:)-clr); - if (ndist < dist) - dist = ndist; - bg = n; - end - end - - %% Compute positions of subbands: - llpos = ones(nind,2); - for lnum = 1:ht - ind1 = nbands*(lnum-1) + 1; - xpos = pind(ind1,2) + 1 + gap*(ht-lnum+1); - ypos = pind(ind1+1,1) + 1 + gap*(ht-lnum+1); - llpos(ind1:ind1+2,:) = [ypos 1; 1 xpos; ypos xpos]; - end - llpos(nind,:) = [1 1]; %lowpass - - %% Make position list positive, and allocate appropriate image: - llpos = llpos - ones(nind,1)*min(llpos) + 1; - urpos = llpos + pind - 1; - d_im = bg + zeros(max(urpos)); - - %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 - for bnum=1:nind - mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); - d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... - mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); - end - - hh = image(d_im); - axis('off'); - pixelAxes(size(d_im),'full'); - set(hh,'UserData',range); - -end diff --git a/evaluation/utils/matlabPyrTools/skew2.m b/evaluation/utils/matlabPyrTools/skew2.m deleted file mode 100755 index 623d6ca..0000000 --- a/evaluation/utils/matlabPyrTools/skew2.m +++ /dev/null @@ -1,21 +0,0 @@ -% S = SKEW2(MTX,MEAN,VAR) -% -% Sample skew (third moment divided by variance^3/2) of a matrix. -% MEAN (optional) and VAR (optional) make the computation faster. - -function res = skew2(mtx, mn, v) - -if (exist('mn') ~= 1) - mn = mean2(mtx); -end - -if (exist('v') ~= 1) - v = var2(mtx,mn); -end - -if (isreal(mtx)) - res = mean(mean((mtx-mn).^3)) / (v^(3/2)); -else - res = mean(mean(real(mtx-mn).^3)) / (real(v)^(3/2)) + ... - i * mean(mean(imag(mtx-mn).^3)) / (imag(v)^(3/2)); -end diff --git a/evaluation/utils/matlabPyrTools/sp0Filters.m b/evaluation/utils/matlabPyrTools/sp0Filters.m deleted file mode 100755 index 6b25e36..0000000 --- a/evaluation/utils/matlabPyrTools/sp0Filters.m +++ /dev/null @@ -1,72 +0,0 @@ -% Steerable pyramid filters. Transform described in: -% -% @INPROCEEDINGS{Simoncelli95b, -% TITLE = "The Steerable Pyramid: A Flexible Architecture for -% Multi-Scale Derivative Computation", -% AUTHOR = "E P Simoncelli and W T Freeman", -% BOOKTITLE = "Second Int'l Conf on Image Processing", -% ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } -% -% Filter kernel design described in: -% -%@INPROCEEDINGS{Karasaridis96, -% TITLE = "A Filter Design Technique for -% Steerable Pyramid Image Transforms", -% AUTHOR = "A Karasaridis and E P Simoncelli", -% BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", -% MONTH = "May", YEAR = 1996 } - -% Eero Simoncelli, 6/96. - -function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp0Filters(); - -harmonics = [ 0 ]; - -lo0filt = [ ... --4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04 --1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 --3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 --3.743860e-03 -7.563200e-03 1.524935e-01 3.153017e-01 1.524935e-01 -7.563200e-03 -3.743860e-03 --3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 --1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 --4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04]; - -lofilt = [ ... --2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04 --8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 --5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 -8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 --1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 --1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 --1.871920e-03 -6.948900e-03 -3.781600e-03 2.449600e-02 7.624674e-02 1.348999e-01 1.576508e-01 1.348999e-01 7.624674e-02 2.449600e-02 -3.781600e-03 -6.948900e-03 -1.871920e-03 --1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 --1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 -8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 --5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 --8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 --2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04]; - -mtx = [ 1.000000 ]; - -hi0filt = [... -5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 --6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 --3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 --3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 --2.406600e-04 -3.732100e-04 -2.420138e-02 -9.623594e-02 8.554893e-01 -9.623594e-02 -2.420138e-02 -3.732100e-04 -2.406600e-04 --3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 --3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 --6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 -5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 ]; - -bfilts = [ ... --9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ... --1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... --4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... --7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... --1.009473e-02 -9.091950e-03 -3.487008e-02 -3.158605e-02 9.464195e-01 -3.158605e-02 -3.487008e-02 -9.091950e-03 -1.009473e-02 ... --7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... --4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... --1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... --9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ]'; - diff --git a/evaluation/utils/matlabPyrTools/sp1Filters.m b/evaluation/utils/matlabPyrTools/sp1Filters.m deleted file mode 100755 index 215e651..0000000 --- a/evaluation/utils/matlabPyrTools/sp1Filters.m +++ /dev/null @@ -1,91 +0,0 @@ -% Steerable pyramid filters. Transform described in: -% -% @INPROCEEDINGS{Simoncelli95b, -% TITLE = "The Steerable Pyramid: A Flexible Architecture for -% Multi-Scale Derivative Computation", -% AUTHOR = "E P Simoncelli and W T Freeman", -% BOOKTITLE = "Second Int'l Conf on Image Processing", -% ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } -% -% Filter kernel design described in: -% -%@INPROCEEDINGS{Karasaridis96, -% TITLE = "A Filter Design Technique for -% Steerable Pyramid Image Transforms", -% AUTHOR = "A Karasaridis and E P Simoncelli", -% BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", -% MONTH = "May", YEAR = 1996 } - -% Eero Simoncelli, 6/96. - -function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp1Filters(); - -harmonics = [ 1 ]; - -%% filters only contain first harmonic. -mtx = eye(2); - -lo0filt = [ ... --8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 --1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 --1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 --5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 -2.524010e-03 1.107620e-03 -3.297137e-02 1.811603e-01 4.376250e-01 1.811603e-01 -3.297137e-02 1.107620e-03 2.524010e-03 --5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 --1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 --1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 --8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 -]; - -lofilt = [ ... --4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ; ... -1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... --6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... --1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... --8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... --1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... --2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... --4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... -1.262000e-03 5.589400e-03 5.538200e-04 -9.637220e-03 -1.648568e-02 1.438512e-02 9.058014e-02 1.773651e-01 2.120374e-01 1.773651e-01 9.058014e-02 1.438512e-02 -1.648568e-02 -9.637220e-03 5.538200e-04 5.589400e-03 1.262000e-03 ; ... --4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... --2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... --1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... --8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... --1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... --6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... -1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... --4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ]; - -hi0filt = [... --9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ; ... --2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... --1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... --8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... --1.166810e-03 1.098012e-02 -5.897780e-03 -1.562827e-01 7.282593e-01 -1.562827e-01 -5.897780e-03 1.098012e-02 -1.166810e-03 ; ... --8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... --1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... --2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... --9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ]; - -bfilts = -[ ... -6.125880e-03 -8.052600e-03 -2.103714e-02 -1.536890e-02 -1.851466e-02 -1.536890e-02 -2.103714e-02 -8.052600e-03 6.125880e-03 ... --1.287416e-02 -9.611520e-03 1.023569e-02 6.009450e-03 1.872620e-03 6.009450e-03 1.023569e-02 -9.611520e-03 -1.287416e-02 ... --5.641530e-03 4.168400e-03 -2.382180e-02 -5.375324e-02 -2.076086e-02 -5.375324e-02 -2.382180e-02 4.168400e-03 -5.641530e-03 ... --8.957260e-03 -1.751170e-03 -1.836909e-02 1.265655e-01 2.996168e-01 1.265655e-01 -1.836909e-02 -1.751170e-03 -8.957260e-03 ... -0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ... -8.957260e-03 1.751170e-03 1.836909e-02 -1.265655e-01 -2.996168e-01 -1.265655e-01 1.836909e-02 1.751170e-03 8.957260e-03 ... -5.641530e-03 -4.168400e-03 2.382180e-02 5.375324e-02 2.076086e-02 5.375324e-02 2.382180e-02 -4.168400e-03 5.641530e-03 ... -1.287416e-02 9.611520e-03 -1.023569e-02 -6.009450e-03 -1.872620e-03 -6.009450e-03 -1.023569e-02 9.611520e-03 1.287416e-02 ... --6.125880e-03 8.052600e-03 2.103714e-02 1.536890e-02 1.851466e-02 1.536890e-02 2.103714e-02 8.052600e-03 -6.125880e-03; ... -... --6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... -8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... -2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... -1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... -1.851466e-02 -1.872620e-03 2.076086e-02 -2.996168e-01 0.000000e+00 2.996168e-01 -2.076086e-02 1.872620e-03 -1.851466e-02 ... -1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... -2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... -8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... --6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... -]'; - diff --git a/evaluation/utils/matlabPyrTools/sp3Filters.m b/evaluation/utils/matlabPyrTools/sp3Filters.m deleted file mode 100755 index c9cfaaf..0000000 --- a/evaluation/utils/matlabPyrTools/sp3Filters.m +++ /dev/null @@ -1,121 +0,0 @@ -% Steerable pyramid filters. Transform described in: -% -% @INPROCEEDINGS{Simoncelli95b, -% TITLE = "The Steerable Pyramid: A Flexible Architecture for -% Multi-Scale Derivative Computation", -% AUTHOR = "E P Simoncelli and W T Freeman", -% BOOKTITLE = "Second Int'l Conf on Image Processing", -% ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } -% -% Filter kernel design described in: -% -%@INPROCEEDINGS{Karasaridis96, -% TITLE = "A Filter Design Technique for -% Steerable Pyramid Image Transforms", -% AUTHOR = "A Karasaridis and E P Simoncelli", -% BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", -% MONTH = "May", YEAR = 1996 } - -% Eero Simoncelli, 6/96. - -function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp3Filters(); - -harmonics = [1 3]; - -mtx = [ ... - 0.5000 0.3536 0 -0.3536 - -0.0000 0.3536 0.5000 0.3536 - 0.5000 -0.3536 0 0.3536 - -0.0000 0.3536 -0.5000 0.3536]; - -hi0filt = [ --4.0483998600E-4 -6.2596000498E-4 -3.7829999201E-5 8.8387000142E-4 1.5450799838E-3 1.9235999789E-3 2.0687500946E-3 2.0898699295E-3 2.0687500946E-3 1.9235999789E-3 1.5450799838E-3 8.8387000142E-4 -3.7829999201E-5 -6.2596000498E-4 -4.0483998600E-4 --6.2596000498E-4 -3.2734998967E-4 7.7435001731E-4 1.5874400269E-3 2.1750701126E-3 2.5626500137E-3 2.2892199922E-3 1.9755100366E-3 2.2892199922E-3 2.5626500137E-3 2.1750701126E-3 1.5874400269E-3 7.7435001731E-4 -3.2734998967E-4 -6.2596000498E-4 --3.7829999201E-5 7.7435001731E-4 1.1793200392E-3 1.4050999889E-3 2.2253401112E-3 2.1145299543E-3 3.3578000148E-4 -8.3368999185E-4 3.3578000148E-4 2.1145299543E-3 2.2253401112E-3 1.4050999889E-3 1.1793200392E-3 7.7435001731E-4 -3.7829999201E-5 -8.8387000142E-4 1.5874400269E-3 1.4050999889E-3 1.2960999738E-3 -4.9274001503E-4 -3.1295299996E-3 -4.5751798898E-3 -5.1014497876E-3 -4.5751798898E-3 -3.1295299996E-3 -4.9274001503E-4 1.2960999738E-3 1.4050999889E-3 1.5874400269E-3 8.8387000142E-4 -1.5450799838E-3 2.1750701126E-3 2.2253401112E-3 -4.9274001503E-4 -6.3222697936E-3 -2.7556000277E-3 5.3632198833E-3 7.3032598011E-3 5.3632198833E-3 -2.7556000277E-3 -6.3222697936E-3 -4.9274001503E-4 2.2253401112E-3 2.1750701126E-3 1.5450799838E-3 -1.9235999789E-3 2.5626500137E-3 2.1145299543E-3 -3.1295299996E-3 -2.7556000277E-3 1.3962360099E-2 7.8046298586E-3 -9.3812197447E-3 7.8046298586E-3 1.3962360099E-2 -2.7556000277E-3 -3.1295299996E-3 2.1145299543E-3 2.5626500137E-3 1.9235999789E-3 -2.0687500946E-3 2.2892199922E-3 3.3578000148E-4 -4.5751798898E-3 5.3632198833E-3 7.8046298586E-3 -7.9501636326E-2 -0.1554141641 -7.9501636326E-2 7.8046298586E-3 5.3632198833E-3 -4.5751798898E-3 3.3578000148E-4 2.2892199922E-3 2.0687500946E-3 -2.0898699295E-3 1.9755100366E-3 -8.3368999185E-4 -5.1014497876E-3 7.3032598011E-3 -9.3812197447E-3 -0.1554141641 0.7303866148 -0.1554141641 -9.3812197447E-3 7.3032598011E-3 -5.1014497876E-3 -8.3368999185E-4 1.9755100366E-3 2.0898699295E-3 -2.0687500946E-3 2.2892199922E-3 3.3578000148E-4 -4.5751798898E-3 5.3632198833E-3 7.8046298586E-3 -7.9501636326E-2 -0.1554141641 -7.9501636326E-2 7.8046298586E-3 5.3632198833E-3 -4.5751798898E-3 3.3578000148E-4 2.2892199922E-3 2.0687500946E-3 -1.9235999789E-3 2.5626500137E-3 2.1145299543E-3 -3.1295299996E-3 -2.7556000277E-3 1.3962360099E-2 7.8046298586E-3 -9.3812197447E-3 7.8046298586E-3 1.3962360099E-2 -2.7556000277E-3 -3.1295299996E-3 2.1145299543E-3 2.5626500137E-3 1.9235999789E-3 -1.5450799838E-3 2.1750701126E-3 2.2253401112E-3 -4.9274001503E-4 -6.3222697936E-3 -2.7556000277E-3 5.3632198833E-3 7.3032598011E-3 5.3632198833E-3 -2.7556000277E-3 -6.3222697936E-3 -4.9274001503E-4 2.2253401112E-3 2.1750701126E-3 1.5450799838E-3 -8.8387000142E-4 1.5874400269E-3 1.4050999889E-3 1.2960999738E-3 -4.9274001503E-4 -3.1295299996E-3 -4.5751798898E-3 -5.1014497876E-3 -4.5751798898E-3 -3.1295299996E-3 -4.9274001503E-4 1.2960999738E-3 1.4050999889E-3 1.5874400269E-3 8.8387000142E-4 --3.7829999201E-5 7.7435001731E-4 1.1793200392E-3 1.4050999889E-3 2.2253401112E-3 2.1145299543E-3 3.3578000148E-4 -8.3368999185E-4 3.3578000148E-4 2.1145299543E-3 2.2253401112E-3 1.4050999889E-3 1.1793200392E-3 7.7435001731E-4 -3.7829999201E-5 --6.2596000498E-4 -3.2734998967E-4 7.7435001731E-4 1.5874400269E-3 2.1750701126E-3 2.5626500137E-3 2.2892199922E-3 1.9755100366E-3 2.2892199922E-3 2.5626500137E-3 2.1750701126E-3 1.5874400269E-3 7.7435001731E-4 -3.2734998967E-4 -6.2596000498E-4 --4.0483998600E-4 -6.2596000498E-4 -3.7829999201E-5 8.8387000142E-4 1.5450799838E-3 1.9235999789E-3 2.0687500946E-3 2.0898699295E-3 2.0687500946E-3 1.9235999789E-3 1.5450799838E-3 8.8387000142E-4 -3.7829999201E-5 -6.2596000498E-4 -4.0483998600E-4 -]; - -lo0filt = [ --8.7009997515E-5 -1.3542800443E-3 -1.6012600390E-3 -5.0337001448E-4 2.5240099058E-3 -5.0337001448E-4 -1.6012600390E-3 -1.3542800443E-3 -8.7009997515E-5 --1.3542800443E-3 2.9215801042E-3 7.5227199122E-3 8.2244202495E-3 1.1076199589E-3 8.2244202495E-3 7.5227199122E-3 2.9215801042E-3 -1.3542800443E-3 --1.6012600390E-3 7.5227199122E-3 -7.0612900890E-3 -3.7694871426E-2 -3.2971370965E-2 -3.7694871426E-2 -7.0612900890E-3 7.5227199122E-3 -1.6012600390E-3 --5.0337001448E-4 8.2244202495E-3 -3.7694871426E-2 4.3813198805E-2 0.1811603010 4.3813198805E-2 -3.7694871426E-2 8.2244202495E-3 -5.0337001448E-4 -2.5240099058E-3 1.1076199589E-3 -3.2971370965E-2 0.1811603010 0.4376249909 0.1811603010 -3.2971370965E-2 1.1076199589E-3 2.5240099058E-3 --5.0337001448E-4 8.2244202495E-3 -3.7694871426E-2 4.3813198805E-2 0.1811603010 4.3813198805E-2 -3.7694871426E-2 8.2244202495E-3 -5.0337001448E-4 --1.6012600390E-3 7.5227199122E-3 -7.0612900890E-3 -3.7694871426E-2 -3.2971370965E-2 -3.7694871426E-2 -7.0612900890E-3 7.5227199122E-3 -1.6012600390E-3 --1.3542800443E-3 2.9215801042E-3 7.5227199122E-3 8.2244202495E-3 1.1076199589E-3 8.2244202495E-3 7.5227199122E-3 2.9215801042E-3 -1.3542800443E-3 --8.7009997515E-5 -1.3542800443E-3 -1.6012600390E-3 -5.0337001448E-4 2.5240099058E-3 -5.0337001448E-4 -1.6012600390E-3 -1.3542800443E-3 -8.7009997515E-5 -]; - -lofilt = [ --4.3500000174E-5 1.2078000145E-4 -6.7714002216E-4 -1.2434000382E-4 -8.0063997302E-4 -1.5970399836E-3 -2.5168000138E-4 -4.2019999819E-4 1.2619999470E-3 -4.2019999819E-4 -2.5168000138E-4 -1.5970399836E-3 -8.0063997302E-4 -1.2434000382E-4 -6.7714002216E-4 1.2078000145E-4 -4.3500000174E-5 -1.2078000145E-4 4.4606000301E-4 -5.8146001538E-4 5.6215998484E-4 -1.3688000035E-4 2.3255399428E-3 2.8898599558E-3 4.2872801423E-3 5.5893999524E-3 4.2872801423E-3 2.8898599558E-3 2.3255399428E-3 -1.3688000035E-4 5.6215998484E-4 -5.8146001538E-4 4.4606000301E-4 1.2078000145E-4 --6.7714002216E-4 -5.8146001538E-4 1.4607800404E-3 2.1605400834E-3 3.7613599561E-3 3.0809799209E-3 4.1121998802E-3 2.2212199401E-3 5.5381999118E-4 2.2212199401E-3 4.1121998802E-3 3.0809799209E-3 3.7613599561E-3 2.1605400834E-3 1.4607800404E-3 -5.8146001538E-4 -6.7714002216E-4 --1.2434000382E-4 5.6215998484E-4 2.1605400834E-3 3.1757799443E-3 3.1846798956E-3 -1.7774800071E-3 -7.4316998944E-3 -9.0569201857E-3 -9.6372198313E-3 -9.0569201857E-3 -7.4316998944E-3 -1.7774800071E-3 3.1846798956E-3 3.1757799443E-3 2.1605400834E-3 5.6215998484E-4 -1.2434000382E-4 --8.0063997302E-4 -1.3688000035E-4 3.7613599561E-3 3.1846798956E-3 -3.5306399222E-3 -1.2604200281E-2 -1.8847439438E-2 -1.7508180812E-2 -1.6485679895E-2 -1.7508180812E-2 -1.8847439438E-2 -1.2604200281E-2 -3.5306399222E-3 3.1846798956E-3 3.7613599561E-3 -1.3688000035E-4 -8.0063997302E-4 --1.5970399836E-3 2.3255399428E-3 3.0809799209E-3 -1.7774800071E-3 -1.2604200281E-2 -2.0229380578E-2 -1.1091699824E-2 3.9556599222E-3 1.4385120012E-2 3.9556599222E-3 -1.1091699824E-2 -2.0229380578E-2 -1.2604200281E-2 -1.7774800071E-3 3.0809799209E-3 2.3255399428E-3 -1.5970399836E-3 --2.5168000138E-4 2.8898599558E-3 4.1121998802E-3 -7.4316998944E-3 -1.8847439438E-2 -1.1091699824E-2 2.1906599402E-2 6.8065837026E-2 9.0580143034E-2 6.8065837026E-2 2.1906599402E-2 -1.1091699824E-2 -1.8847439438E-2 -7.4316998944E-3 4.1121998802E-3 2.8898599558E-3 -2.5168000138E-4 --4.2019999819E-4 4.2872801423E-3 2.2212199401E-3 -9.0569201857E-3 -1.7508180812E-2 3.9556599222E-3 6.8065837026E-2 0.1445499808 0.1773651242 0.1445499808 6.8065837026E-2 3.9556599222E-3 -1.7508180812E-2 -9.0569201857E-3 2.2212199401E-3 4.2872801423E-3 -4.2019999819E-4 -1.2619999470E-3 5.5893999524E-3 5.5381999118E-4 -9.6372198313E-3 -1.6485679895E-2 1.4385120012E-2 9.0580143034E-2 0.1773651242 0.2120374441 0.1773651242 9.0580143034E-2 1.4385120012E-2 -1.6485679895E-2 -9.6372198313E-3 5.5381999118E-4 5.5893999524E-3 1.2619999470E-3 --4.2019999819E-4 4.2872801423E-3 2.2212199401E-3 -9.0569201857E-3 -1.7508180812E-2 3.9556599222E-3 6.8065837026E-2 0.1445499808 0.1773651242 0.1445499808 6.8065837026E-2 3.9556599222E-3 -1.7508180812E-2 -9.0569201857E-3 2.2212199401E-3 4.2872801423E-3 -4.2019999819E-4 --2.5168000138E-4 2.8898599558E-3 4.1121998802E-3 -7.4316998944E-3 -1.8847439438E-2 -1.1091699824E-2 2.1906599402E-2 6.8065837026E-2 9.0580143034E-2 6.8065837026E-2 2.1906599402E-2 -1.1091699824E-2 -1.8847439438E-2 -7.4316998944E-3 4.1121998802E-3 2.8898599558E-3 -2.5168000138E-4 --1.5970399836E-3 2.3255399428E-3 3.0809799209E-3 -1.7774800071E-3 -1.2604200281E-2 -2.0229380578E-2 -1.1091699824E-2 3.9556599222E-3 1.4385120012E-2 3.9556599222E-3 -1.1091699824E-2 -2.0229380578E-2 -1.2604200281E-2 -1.7774800071E-3 3.0809799209E-3 2.3255399428E-3 -1.5970399836E-3 --8.0063997302E-4 -1.3688000035E-4 3.7613599561E-3 3.1846798956E-3 -3.5306399222E-3 -1.2604200281E-2 -1.8847439438E-2 -1.7508180812E-2 -1.6485679895E-2 -1.7508180812E-2 -1.8847439438E-2 -1.2604200281E-2 -3.5306399222E-3 3.1846798956E-3 3.7613599561E-3 -1.3688000035E-4 -8.0063997302E-4 --1.2434000382E-4 5.6215998484E-4 2.1605400834E-3 3.1757799443E-3 3.1846798956E-3 -1.7774800071E-3 -7.4316998944E-3 -9.0569201857E-3 -9.6372198313E-3 -9.0569201857E-3 -7.4316998944E-3 -1.7774800071E-3 3.1846798956E-3 3.1757799443E-3 2.1605400834E-3 5.6215998484E-4 -1.2434000382E-4 --6.7714002216E-4 -5.8146001538E-4 1.4607800404E-3 2.1605400834E-3 3.7613599561E-3 3.0809799209E-3 4.1121998802E-3 2.2212199401E-3 5.5381999118E-4 2.2212199401E-3 4.1121998802E-3 3.0809799209E-3 3.7613599561E-3 2.1605400834E-3 1.4607800404E-3 -5.8146001538E-4 -6.7714002216E-4 -1.2078000145E-4 4.4606000301E-4 -5.8146001538E-4 5.6215998484E-4 -1.3688000035E-4 2.3255399428E-3 2.8898599558E-3 4.2872801423E-3 5.5893999524E-3 4.2872801423E-3 2.8898599558E-3 2.3255399428E-3 -1.3688000035E-4 5.6215998484E-4 -5.8146001538E-4 4.4606000301E-4 1.2078000145E-4 --4.3500000174E-5 1.2078000145E-4 -6.7714002216E-4 -1.2434000382E-4 -8.0063997302E-4 -1.5970399836E-3 -2.5168000138E-4 -4.2019999819E-4 1.2619999470E-3 -4.2019999819E-4 -2.5168000138E-4 -1.5970399836E-3 -8.0063997302E-4 -1.2434000382E-4 -6.7714002216E-4 1.2078000145E-4 -4.3500000174E-5 -]; - -bfilts = [... --8.1125000725E-4 4.4451598078E-3 1.2316980399E-2 1.3955879956E-2 1.4179450460E-2 1.3955879956E-2 1.2316980399E-2 4.4451598078E-3 -8.1125000725E-4 ... -3.9103501476E-3 4.4565401040E-3 -5.8724298142E-3 -2.8760801069E-3 8.5267601535E-3 -2.8760801069E-3 -5.8724298142E-3 4.4565401040E-3 3.9103501476E-3 ... -1.3462699717E-3 -3.7740699481E-3 8.2581602037E-3 3.9442278445E-2 5.3605638444E-2 3.9442278445E-2 8.2581602037E-3 -3.7740699481E-3 1.3462699717E-3 ... -7.4700999539E-4 -3.6522001028E-4 -2.2522680461E-2 -0.1105690673 -0.1768419296 -0.1105690673 -2.2522680461E-2 -3.6522001028E-4 7.4700999539E-4 ... -0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ... --7.4700999539E-4 3.6522001028E-4 2.2522680461E-2 0.1105690673 0.1768419296 0.1105690673 2.2522680461E-2 3.6522001028E-4 -7.4700999539E-4 ... --1.3462699717E-3 3.7740699481E-3 -8.2581602037E-3 -3.9442278445E-2 -5.3605638444E-2 -3.9442278445E-2 -8.2581602037E-3 3.7740699481E-3 -1.3462699717E-3 ... --3.9103501476E-3 -4.4565401040E-3 5.8724298142E-3 2.8760801069E-3 -8.5267601535E-3 2.8760801069E-3 5.8724298142E-3 -4.4565401040E-3 -3.9103501476E-3 ... -8.1125000725E-4 -4.4451598078E-3 -1.2316980399E-2 -1.3955879956E-2 -1.4179450460E-2 -1.3955879956E-2 -1.2316980399E-2 -4.4451598078E-3 8.1125000725E-4; ... -... -0.0000000000 -8.2846998703E-4 -5.7109999034E-5 4.0110000555E-5 4.6670897864E-3 8.0871898681E-3 1.4807609841E-2 8.6204400286E-3 -3.1221499667E-3 ... -8.2846998703E-4 0.0000000000 -9.7479997203E-4 -6.9718998857E-3 -2.0865600090E-3 2.3298799060E-3 -4.4814897701E-3 1.4917500317E-2 8.6204400286E-3 ... -5.7109999034E-5 9.7479997203E-4 0.0000000000 -1.2145539746E-2 -2.4427289143E-2 5.0797060132E-2 3.2785870135E-2 -4.4814897701E-3 1.4807609841E-2 ... --4.0110000555E-5 6.9718998857E-3 1.2145539746E-2 0.0000000000 -0.1510555595 -8.2495503128E-2 5.0797060132E-2 2.3298799060E-3 8.0871898681E-3 ... --4.6670897864E-3 2.0865600090E-3 2.4427289143E-2 0.1510555595 0.0000000000 -0.1510555595 -2.4427289143E-2 -2.0865600090E-3 4.6670897864E-3 ... --8.0871898681E-3 -2.3298799060E-3 -5.0797060132E-2 8.2495503128E-2 0.1510555595 0.0000000000 -1.2145539746E-2 -6.9718998857E-3 4.0110000555E-5 ... --1.4807609841E-2 4.4814897701E-3 -3.2785870135E-2 -5.0797060132E-2 2.4427289143E-2 1.2145539746E-2 0.0000000000 -9.7479997203E-4 -5.7109999034E-5 ... --8.6204400286E-3 -1.4917500317E-2 4.4814897701E-3 -2.3298799060E-3 2.0865600090E-3 6.9718998857E-3 9.7479997203E-4 0.0000000000 -8.2846998703E-4 ... -3.1221499667E-3 -8.6204400286E-3 -1.4807609841E-2 -8.0871898681E-3 -4.6670897864E-3 -4.0110000555E-5 5.7109999034E-5 8.2846998703E-4 0.0000000000; ... -... -8.1125000725E-4 -3.9103501476E-3 -1.3462699717E-3 -7.4700999539E-4 0.0000000000 7.4700999539E-4 1.3462699717E-3 3.9103501476E-3 -8.1125000725E-4 ... --4.4451598078E-3 -4.4565401040E-3 3.7740699481E-3 3.6522001028E-4 0.0000000000 -3.6522001028E-4 -3.7740699481E-3 4.4565401040E-3 4.4451598078E-3 ... --1.2316980399E-2 5.8724298142E-3 -8.2581602037E-3 2.2522680461E-2 0.0000000000 -2.2522680461E-2 8.2581602037E-3 -5.8724298142E-3 1.2316980399E-2 ... --1.3955879956E-2 2.8760801069E-3 -3.9442278445E-2 0.1105690673 0.0000000000 -0.1105690673 3.9442278445E-2 -2.8760801069E-3 1.3955879956E-2 ... --1.4179450460E-2 -8.5267601535E-3 -5.3605638444E-2 0.1768419296 0.0000000000 -0.1768419296 5.3605638444E-2 8.5267601535E-3 1.4179450460E-2 ... --1.3955879956E-2 2.8760801069E-3 -3.9442278445E-2 0.1105690673 0.0000000000 -0.1105690673 3.9442278445E-2 -2.8760801069E-3 1.3955879956E-2 ... --1.2316980399E-2 5.8724298142E-3 -8.2581602037E-3 2.2522680461E-2 0.0000000000 -2.2522680461E-2 8.2581602037E-3 -5.8724298142E-3 1.2316980399E-2 ... --4.4451598078E-3 -4.4565401040E-3 3.7740699481E-3 3.6522001028E-4 0.0000000000 -3.6522001028E-4 -3.7740699481E-3 4.4565401040E-3 4.4451598078E-3 ... -8.1125000725E-4 -3.9103501476E-3 -1.3462699717E-3 -7.4700999539E-4 0.0000000000 7.4700999539E-4 1.3462699717E-3 3.9103501476E-3 -8.1125000725E-4; ... -... -3.1221499667E-3 -8.6204400286E-3 -1.4807609841E-2 -8.0871898681E-3 -4.6670897864E-3 -4.0110000555E-5 5.7109999034E-5 8.2846998703E-4 0.0000000000 ... --8.6204400286E-3 -1.4917500317E-2 4.4814897701E-3 -2.3298799060E-3 2.0865600090E-3 6.9718998857E-3 9.7479997203E-4 -0.0000000000 -8.2846998703E-4 ... --1.4807609841E-2 4.4814897701E-3 -3.2785870135E-2 -5.0797060132E-2 2.4427289143E-2 1.2145539746E-2 0.0000000000 -9.7479997203E-4 -5.7109999034E-5 ... --8.0871898681E-3 -2.3298799060E-3 -5.0797060132E-2 8.2495503128E-2 0.1510555595 -0.0000000000 -1.2145539746E-2 -6.9718998857E-3 4.0110000555E-5 ... --4.6670897864E-3 2.0865600090E-3 2.4427289143E-2 0.1510555595 0.0000000000 -0.1510555595 -2.4427289143E-2 -2.0865600090E-3 4.6670897864E-3 ... --4.0110000555E-5 6.9718998857E-3 1.2145539746E-2 0.0000000000 -0.1510555595 -8.2495503128E-2 5.0797060132E-2 2.3298799060E-3 8.0871898681E-3 ... -5.7109999034E-5 9.7479997203E-4 -0.0000000000 -1.2145539746E-2 -2.4427289143E-2 5.0797060132E-2 3.2785870135E-2 -4.4814897701E-3 1.4807609841E-2 ... -8.2846998703E-4 -0.0000000000 -9.7479997203E-4 -6.9718998857E-3 -2.0865600090E-3 2.3298799060E-3 -4.4814897701E-3 1.4917500317E-2 8.6204400286E-3 ... -0.0000000000 -8.2846998703E-4 -5.7109999034E-5 4.0110000555E-5 4.6670897864E-3 8.0871898681E-3 1.4807609841E-2 8.6204400286E-3 -3.1221499667E-3 ... -]'; diff --git a/evaluation/utils/matlabPyrTools/sp5Filters.m b/evaluation/utils/matlabPyrTools/sp5Filters.m deleted file mode 100755 index 4cddcfd..0000000 --- a/evaluation/utils/matlabPyrTools/sp5Filters.m +++ /dev/null @@ -1,110 +0,0 @@ -% Steerable pyramid filters. Transform described in: -% -% @INPROCEEDINGS{Simoncelli95b, -% TITLE = "The Steerable Pyramid: A Flexible Architecture for -% Multi-Scale Derivative Computation", -% AUTHOR = "E P Simoncelli and W T Freeman", -% BOOKTITLE = "Second Int'l Conf on Image Processing", -% ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } -% -% Filter kernel design described in: -% -%@INPROCEEDINGS{Karasaridis96, -% TITLE = "A Filter Design Technique for -% Steerable Pyramid Image Transforms", -% AUTHOR = "A Karasaridis and E P Simoncelli", -% BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", -% MONTH = "May", YEAR = 1996 } - -% Eero Simoncelli, 6/96. - -function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp5Filters(); - -harmonics = [1 3 5]; - -mtx = [ ... - 0.3333 0.2887 0.1667 0.0000 -0.1667 -0.2887 - 0.0000 0.1667 0.2887 0.3333 0.2887 0.1667 - 0.3333 -0.0000 -0.3333 -0.0000 0.3333 -0.0000 - 0.0000 0.3333 0.0000 -0.3333 0.0000 0.3333 - 0.3333 -0.2887 0.1667 -0.0000 -0.1667 0.2887 - -0.0000 0.1667 -0.2887 0.3333 -0.2887 0.1667]; - -hi0filt = [ --0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429 --0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 --0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 --0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 --0.00080639 0.01261227 -0.00981051 -0.11435863 0.81380200 -0.11435863 -0.00981051 0.01261227 -0.00080639 --0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 --0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 --0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 --0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429]; - - -lo0filt = [ -0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614 --0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 --0.03848215 0.15925570 0.40304148 0.15925570 -0.03848215 --0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 -0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614]; - -lofilt = 2*[ -0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404 --0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 --0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 --0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 --0.00962054 0.01002988 0.03981393 0.08169618 0.10096540 0.08169618 0.03981393 0.01002988 -0.00962054 --0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 --0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 --0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 -0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404]; - -bfilts = [... - 0.00277643 0.00496194 0.01026699 0.01455399 0.01026699 0.00496194 0.00277643 ... --0.00986904 -0.00893064 0.01189859 0.02755155 0.01189859 -0.00893064 -0.00986904 ... --0.01021852 -0.03075356 -0.08226445 -0.11732297 -0.08226445 -0.03075356 -0.01021852 ... - 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 ... - 0.01021852 0.03075356 0.08226445 0.11732297 0.08226445 0.03075356 0.01021852 ... - 0.00986904 0.00893064 -0.01189859 -0.02755155 -0.01189859 0.00893064 0.00986904 ... --0.00277643 -0.00496194 -0.01026699 -0.01455399 -0.01026699 -0.00496194 -0.00277643; -... --0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982 ... --0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... - 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... - 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... - 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... --0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... --0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249; -... - 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982 ... - 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... - 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... --0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... --0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... --0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... --0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249; -... --0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643 ... --0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... --0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... --0.01455399 -0.02755155 0.11732297 -0.00000000 -0.11732297 0.02755155 0.01455399 ... --0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... --0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... --0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643; -... --0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249 ... --0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... --0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... --0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... - 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... - 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... - 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982; -... --0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249 ... --0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... - 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... - 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... - 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... --0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... --0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982]'; diff --git a/evaluation/utils/matlabPyrTools/spyrBand.m b/evaluation/utils/matlabPyrTools/spyrBand.m deleted file mode 100755 index 474a8dc..0000000 --- a/evaluation/utils/matlabPyrTools/spyrBand.m +++ /dev/null @@ -1,34 +0,0 @@ -% [LEV,IND] = spyrBand(PYR,INDICES,LEVEL,BAND) -% -% Access a band from a steerable pyramid. -% -% LEVEL indicates the scale (finest = 1, coarsest = spyrHt(INDICES)). -% -% BAND (optional, default=1) indicates which subband -% (1 = vertical, rest proceeding anti-clockwise). - -% Eero Simoncelli, 6/96. - -function res = spyrBand(pyr,pind,level,band) - -if (exist('level') ~= 1) - level = 1; -end - -if (exist('band') ~= 1) - band = 1; -end - -nbands = spyrNumBands(pind); -if ((band > nbands) | (band < 1)) - error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); -end - -maxLev = spyrHt(pind); -if ((level > maxLev) | (level < 1)) - error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); -end - -firstband = 1 + band + nbands*(level-1); -res = pyrBand(pyr, pind, firstband); - diff --git a/evaluation/utils/matlabPyrTools/spyrHigh.m b/evaluation/utils/matlabPyrTools/spyrHigh.m deleted file mode 100755 index f91b466..0000000 --- a/evaluation/utils/matlabPyrTools/spyrHigh.m +++ /dev/null @@ -1,10 +0,0 @@ -% RES = spyrHigh(PYR, INDICES) -% -% Access the highpass residual band from a steerable pyramid. - -% Eero Simoncelli, 6/96. - -function res = spyrHigh(pyr,pind) - -res = pyrBand(pyr, pind, 1); - diff --git a/evaluation/utils/matlabPyrTools/spyrHt.m b/evaluation/utils/matlabPyrTools/spyrHt.m deleted file mode 100755 index 8706b9e..0000000 --- a/evaluation/utils/matlabPyrTools/spyrHt.m +++ /dev/null @@ -1,16 +0,0 @@ -% [HEIGHT] = spyrHt(INDICES) -% -% Compute height of steerable pyramid with given index matrix. - -% Eero Simoncelli, 6/96. - -function [ht] = spyrHt(pind) - -nbands = spyrNumBands(pind); - -% Don't count lowpass, or highpass residual bands -if (size(pind,1) > 2) - ht = (size(pind,1)-2)/nbands; -else - ht = 0; -end diff --git a/evaluation/utils/matlabPyrTools/spyrLev.m b/evaluation/utils/matlabPyrTools/spyrLev.m deleted file mode 100755 index 5cb4a85..0000000 --- a/evaluation/utils/matlabPyrTools/spyrLev.m +++ /dev/null @@ -1,24 +0,0 @@ -% [LEV,IND] = spyrLev(PYR,INDICES,LEVEL) -% -% Access a level from a steerable pyramid. -% Return as an SxB matrix, B = number of bands, S = total size of a band. -% Also returns an Bx2 matrix containing dimensions of the subbands. - -% Eero Simoncelli, 6/96. - -function [lev,ind] = spyrLev(pyr,pind,level) - -nbands = spyrNumBands(pind); - -if ((level > spyrHt(pind)) | (level < 1)) - error(sprintf('Level number must be in the range [1, %d].', spyrHt(pind))); -end - -firstband = 2 + nbands*(level-1); -firstind = 1; -for l=1:firstband-1 - firstind = firstind + prod(pind(l,:)); -end - -ind = pind(firstband:firstband+nbands-1,:); -lev = pyr(firstind:firstind+sum(prod(ind'))-1); diff --git a/evaluation/utils/matlabPyrTools/spyrNumBands.m b/evaluation/utils/matlabPyrTools/spyrNumBands.m deleted file mode 100755 index 68aec3f..0000000 --- a/evaluation/utils/matlabPyrTools/spyrNumBands.m +++ /dev/null @@ -1,20 +0,0 @@ -% [NBANDS] = spyrNumBands(INDICES) -% -% Compute number of orientation bands in a steerable pyramid with -% given index matrix. If the pyramid contains only the highpass and -% lowpass bands (i.e., zero levels), returns 0. - -% Eero Simoncelli, 2/97. - -function [nbands] = spyrNumBands(pind) - -if (size(pind,1) == 2) - nbands = 0; -else - % Count number of orientation bands: - b = 3; - while ((b <= size(pind,1)) & all( pind(b,:) == pind(2,:)) ) - b = b+1; - end - nbands = b-2; -end diff --git a/evaluation/utils/matlabPyrTools/steer.m b/evaluation/utils/matlabPyrTools/steer.m deleted file mode 100755 index 8f9c2ac..0000000 --- a/evaluation/utils/matlabPyrTools/steer.m +++ /dev/null @@ -1,68 +0,0 @@ -% RES = STEER(BASIS, ANGLE, HARMONICS, STEERMTX) -% -% Steer BASIS to the specfied ANGLE. -% -% BASIS should be a matrix whose columns are vectorized rotated copies of a -% steerable function, or the responses of a set of steerable filters. -% -% ANGLE can be a scalar, or a column vector the size of the basis. -% -% HARMONICS (optional, default is N even or odd low frequencies, as for -% derivative filters) should be a list of harmonic numbers indicating -% the angular harmonic content of the basis. -% -% STEERMTX (optional, default assumes cosine phase harmonic components, -% and filter positions at 2pi*n/N) should be a matrix which maps -% the filters onto Fourier series components (ordered [cos0 cos1 sin1 -% cos2 sin2 ... sinN]). See steer2HarmMtx.m - -% Eero Simoncelli, 7/96. - -function res = steer(basis,angle,harmonics,steermtx) - -num = size(basis,2); - -if ( any(size(angle) ~= [size(basis,1) 1]) & any(size(angle) ~= [1 1]) ) - error('ANGLE must be a scalar, or a column vector the size of the basis elements'); -end - -%% If HARMONICS are not passed, assume derivatives. -if (exist('harmonics') ~= 1) - if (mod(num,2) == 0) - harmonics = [0:(num/2)-1]'*2 + 1; - else - harmonics = [0:(num-1)/2]'*2; - end -else - harmonics = harmonics(:); - if ((2*size(harmonics,1)-any(harmonics == 0)) ~= num) - error('harmonics list is incompatible with basis size'); - end -end - -%% If STEERMTX not passed, assume evenly distributed cosine-phase filters: -if (exist('steermtx') ~= 1) - steermtx = steer2HarmMtx(harmonics, pi*[0:num-1]/num, 'even'); -end - -steervect = zeros(size(angle,1),num); -arg = angle * harmonics(find(harmonics~=0))'; -if (all(harmonics)) - steervect(:, 1:2:num) = cos(arg); - steervect(:, 2:2:num) = sin(arg); -else - steervect(:, 1) = ones(size(arg,1),1); - steervect(:, 2:2:num) = cos(arg); - steervect(:, 3:2:num) = sin(arg); -end - -steervect = steervect * steermtx; - -if (size(steervect,1) > 1) - tmp = basis' .* steervect'; - res = sum(tmp)'; -else - res = basis * steervect'; -end - - diff --git a/evaluation/utils/matlabPyrTools/steer2HarmMtx.m b/evaluation/utils/matlabPyrTools/steer2HarmMtx.m deleted file mode 100755 index 1f3e80e..0000000 --- a/evaluation/utils/matlabPyrTools/steer2HarmMtx.m +++ /dev/null @@ -1,71 +0,0 @@ -% MTX = steer2HarmMtx(HARMONICS, ANGLES, REL_PHASES) -% -% Compute a steering matrix (maps a directional basis set onto the -% angular Fourier harmonics). HARMONICS is a vector specifying the -% angular harmonics contained in the steerable basis/filters. ANGLES -% (optional) is a vector specifying the angular position of each filter. -% REL_PHASES (optional, default = 'even') specifies whether the harmonics -% are cosine or sine phase aligned about those positions. -% The result matrix is suitable for passing to the function STEER. - -% Eero Simoncelli, 7/96. - -function mtx = steer2HarmMtx(harmonics, angles, evenorodd) - -%%================================================================= -%%% Optional Parameters: - -if (exist('evenorodd') ~= 1) - evenorodd = 'even'; -end - -% Make HARMONICS a row vector -harmonics = harmonics(:)'; - -numh = 2*size(harmonics,2) - any(harmonics == 0); - -if (exist('angles') ~= 1) - angles = pi * [0:numh-1]'/numh; -else - angles = angles(:); -end - -%%================================================================= - -if isstr(evenorodd) - if strcmp(evenorodd,'even') - evenorodd = 0; - elseif strcmp(evenorodd,'odd') - evenorodd = 1; - else - error('EVEN_OR_ODD should be the string EVEN or ODD'); - end -end - -%% Compute inverse matrix, which maps Fourier components onto -%% steerable basis. -imtx = zeros(size(angles,1),numh); -col = 1; -for h=harmonics - args = h*angles; - if (h == 0) - imtx(:,col) = ones(size(angles)); - col = col+1; - elseif evenorodd - imtx(:,col) = sin(args); - imtx(:,col+1) = -cos(args); - col = col+2; - else - imtx(:,col) = cos(args); - imtx(:,col+1) = sin(args); - col = col+2; - end -end - -r = rank(imtx); -if (( r ~= numh ) & ( r ~= size(angles,1) )) - fprintf(2,'WARNING: matrix is not full rank'); -end - -mtx = pinv(imtx); - diff --git a/evaluation/utils/matlabPyrTools/subMtx.m b/evaluation/utils/matlabPyrTools/subMtx.m deleted file mode 100755 index ea3c2ea..0000000 --- a/evaluation/utils/matlabPyrTools/subMtx.m +++ /dev/null @@ -1,21 +0,0 @@ -% MTX = subMtx(VEC, DIMENSIONS, START_INDEX) -% -% Reshape a portion of VEC starting from START_INDEX (optional, -% default=1) to the given dimensions. - -% Eero Simoncelli, 6/96. - -function mtx = subMtx(vec, sz, offset) - -if (exist('offset') ~= 1) - offset = 1; -end - -vec = vec(:); -sz = sz(:); - -if (size(sz,1) ~= 2) - error('DIMENSIONS must be a 2-vector.'); -end - -mtx = reshape( vec(offset:offset+prod(sz)-1), sz(1), sz(2) ); diff --git a/evaluation/utils/matlabPyrTools/upBlur.m b/evaluation/utils/matlabPyrTools/upBlur.m deleted file mode 100755 index 948c2e1..0000000 --- a/evaluation/utils/matlabPyrTools/upBlur.m +++ /dev/null @@ -1,52 +0,0 @@ -% RES = upBlur(IM, LEVELS, FILT) -% -% Upsample and blur an image. The blurring is done with filter -% kernel specified by FILT (default = 'binom5'), which can be a string -% (to be passed to namedFilter), a vector (applied separably as a 1D -% convolution kernel in X and Y), or a matrix (applied as a 2D -% convolution kernel). The downsampling is always by 2 in each -% direction. -% -% The procedure is applied recursively LEVELS times (default=1). - -% Eero Simoncelli, 4/97. - -function res = upBlur(im, nlevs, filt) - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('nlevs') ~= 1) - nlevs = 1; -end - -if (exist('filt') ~= 1) - filt = 'binom5'; -end - -%------------------------------------------------------------ - -if isstr(filt) - filt = namedFilter(filt); -end - -if nlevs > 1 - im = upBlur(im,nlevs-1,filt); -end - -if (nlevs >= 1) - if (any(size(im)==1)) - if (size(im,1)==1) - filt = filt'; - end - res = upConv(im,filt,'reflect1',(size(im)~=1)+1); - elseif (any(size(filt)==1)) - filt = filt(:); - res = upConv(im,filt,'reflect1',[2 1]); - res = upConv(res,filt','reflect1',[1 2]); - else - res = upConv(im,filt,'reflect1',[2 2]); - end -else - res = im; -end diff --git a/evaluation/utils/matlabPyrTools/upConv.m b/evaluation/utils/matlabPyrTools/upConv.m deleted file mode 100755 index 4d1ffd9..0000000 --- a/evaluation/utils/matlabPyrTools/upConv.m +++ /dev/null @@ -1,80 +0,0 @@ -% RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES) -% -% Upsample matrix IM, followed by convolution with matrix FILT. These -% arguments should be 1D or 2D matrices, and IM must be larger (in -% both dimensions) than FILT. The origin of filt -% is assumed to be floor(size(filt)/2)+1. -% -% EDGES is a string determining boundary handling: -% 'circular' - Circular convolution -% 'reflect1' - Reflect about the edge pixels -% 'reflect2' - Reflect, doubling the edge pixels -% 'repeat' - Repeat the edge pixels -% 'zero' - Assume values of zero outside image boundary -% 'extend' - Reflect and invert -% 'dont-compute' - Zero output when filter overhangs OUTPUT boundaries -% -% Upsampling factors are determined by STEP (optional, default=[1 1]), -% a 2-vector [y,x]. -% -% The window over which the convolution occurs is specfied by START -% (optional, default=[1,1], and STOP (optional, default = -% step .* (size(IM) + floor((start-1)./step))). -% -% RES is an optional result matrix. The convolution result will be -% destructively added into this matrix. If this argument is passed, the -% result matrix will not be returned. DO NOT USE THIS ARGUMENT IF -% YOU DO NOT UNDERSTAND WHAT THIS MEANS!! -% -% NOTE: this operation corresponds to multiplication of a signal -% vector by a matrix whose columns contain copies of the time-reversed -% (or space-reversed) FILT shifted by multiples of STEP. See corrDn.m -% for the operation corresponding to the transpose of this matrix. - -% Eero Simoncelli, 6/96. revised 2/97. - -function result = upConv(im,filt,edges,step,start,stop,res) - -%% THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) - -fprintf(1,'WARNING: You should compile the MEX version of "upConv.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); - -%------------------------------------------------------------ -%% OPTIONAL ARGS: - -if (exist('edges') == 1) - if (strcmp(edges,'reflect1') ~= 1) - warning('Using REFLECT1 edge-handling (use MEX code for other options).'); - end -end - -if (exist('step') ~= 1) - step = [1,1]; -end - -if (exist('start') ~= 1) - start = [1,1]; -end - -% A multiple of step -if (exist('stop') ~= 1) - stop = step .* (floor((start-ones(size(start)))./step)+size(im)) -end - -if ( ceil((stop(1)+1-start(1)) / step(1)) ~= size(im,1) ) - error('Bad Y result dimension'); -end -if ( ceil((stop(2)+1-start(2)) / step(2)) ~= size(im,2) ) - error('Bad X result dimension'); -end - -if (exist('res') ~= 1) - res = zeros(stop-start+1); -end - -%------------------------------------------------------------ - -tmp = zeros(size(res)); -tmp(start(1):step(1):stop(1),start(2):step(2):stop(2)) = im; - -result = rconv2(tmp,filt) + res; diff --git a/evaluation/utils/matlabPyrTools/upConv.mexa64 b/evaluation/utils/matlabPyrTools/upConv.mexa64 deleted file mode 100755 index e38c594..0000000 Binary files a/evaluation/utils/matlabPyrTools/upConv.mexa64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/upConv.mexglx b/evaluation/utils/matlabPyrTools/upConv.mexglx deleted file mode 100755 index 3b12479..0000000 Binary files a/evaluation/utils/matlabPyrTools/upConv.mexglx and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/upConv.mexmac b/evaluation/utils/matlabPyrTools/upConv.mexmac deleted file mode 100755 index 98e7560..0000000 Binary files a/evaluation/utils/matlabPyrTools/upConv.mexmac and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/upConv.mexmaci64 b/evaluation/utils/matlabPyrTools/upConv.mexmaci64 deleted file mode 100755 index b06df9a..0000000 Binary files a/evaluation/utils/matlabPyrTools/upConv.mexmaci64 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/upConv.mexw32 b/evaluation/utils/matlabPyrTools/upConv.mexw32 deleted file mode 100755 index 36d5011..0000000 Binary files a/evaluation/utils/matlabPyrTools/upConv.mexw32 and /dev/null differ diff --git a/evaluation/utils/matlabPyrTools/var2.m b/evaluation/utils/matlabPyrTools/var2.m deleted file mode 100755 index 6957eff..0000000 --- a/evaluation/utils/matlabPyrTools/var2.m +++ /dev/null @@ -1,17 +0,0 @@ -% V = VAR2(MTX,MEAN) -% -% Sample variance of a matrix. -% Passing MEAN (optional) makes the calculation faster. - -function res = var2(mtx, mn) - -if (exist('mn') ~= 1) - mn = mean2(mtx); -end - -if (isreal(mtx)) - res = sum(sum(abs(mtx-mn).^2)) / max((prod(size(mtx)) - 1),1); -else - res = sum(sum(real(mtx-mn).^2)) + i*sum(sum(imag(mtx-mn).^2)); - res = res / max((prod(size(mtx)) - 1),1); -end diff --git a/evaluation/utils/matlabPyrTools/vectify.m b/evaluation/utils/matlabPyrTools/vectify.m deleted file mode 100755 index 3664223..0000000 --- a/evaluation/utils/matlabPyrTools/vectify.m +++ /dev/null @@ -1,8 +0,0 @@ -% [VEC] = columnize(MTX) -% -% Pack elements of MTX into a column vector. Just provides a -% function-call notatoin for the operation MTX(:) - -function vec = columnize(mtx) - -vec = mtx(:); diff --git a/evaluation/utils/matlabPyrTools/wpyrBand.m b/evaluation/utils/matlabPyrTools/wpyrBand.m deleted file mode 100755 index c027cca..0000000 --- a/evaluation/utils/matlabPyrTools/wpyrBand.m +++ /dev/null @@ -1,39 +0,0 @@ -% RES = wpyrBand(PYR, INDICES, LEVEL, BAND) -% -% Access a subband from a separable QMF/wavelet pyramid. -% -% LEVEL (optional, default=1) indicates the scale (finest = 1, -% coarsest = wpyrHt(INDICES)). -% -% BAND (optional, default=1) indicates which subband (1=horizontal, -% 2=vertical, 3=diagonal). - -% Eero Simoncelli, 6/96. - -function im = wpyrBand(pyr,pind,level,band) - -if (exist('level') ~= 1) - level = 1; -end - -if (exist('band') ~= 1) - band = 1; -end - -if ((pind(1,1) == 1) | (pind(1,2) ==1)) - nbands = 1; -else - nbands = 3; -end - -if ((band > nbands) | (band < 1)) - error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); -end - -maxLev = wpyrHt(pind); -if ((level > maxLev) | (level < 1)) - error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); -end - -band = band + nbands*(level-1); -im = pyrBand(pyr,pind,band); diff --git a/evaluation/utils/matlabPyrTools/wpyrHt.m b/evaluation/utils/matlabPyrTools/wpyrHt.m deleted file mode 100755 index 476be83..0000000 --- a/evaluation/utils/matlabPyrTools/wpyrHt.m +++ /dev/null @@ -1,15 +0,0 @@ -% [HEIGHT] = wpyrHt(INDICES) -% -% Compute height of separable QMF/wavelet pyramid with given index matrix. - -% Eero Simoncelli, 6/96. - -function [ht] = wpyrHt(pind) - -if ((pind(1,1) == 1) | (pind(1,2) ==1)) - nbands = 1; -else - nbands = 3; -end - -ht = (size(pind,1)-1)/nbands; diff --git a/evaluation/utils/matlabPyrTools/wpyrLev.m b/evaluation/utils/matlabPyrTools/wpyrLev.m deleted file mode 100755 index 18f30ae..0000000 --- a/evaluation/utils/matlabPyrTools/wpyrLev.m +++ /dev/null @@ -1,30 +0,0 @@ -% [LEV,IND] = wpyrLev(PYR,INDICES,LEVEL) -% -% Access a level from a separable QMF/wavelet pyramid. -% Return as an SxB matrix, B = number of bands, S = total size of a band. -% Also returns an Bx2 matrix containing dimensions of the subbands. - -% Eero Simoncelli, 6/96. - -function [lev,ind] = wpyrLev(pyr,pind,level) - -if ((pind(1,1) == 1) | (pind(1,2) ==1)) - nbands = 1; -else - nbands = 3; -end - -if ((level > wpyrHt(pind)) | (level < 1)) - error(sprintf('Level number must be in the range [1, %d].', wpyrHt(pind))); -end - -firstband = 1 + nbands*(level-1) -firstind = 1; -for l=1:firstband-1 - firstind = firstind + prod(pind(l,:)); -end - - -ind = pind(firstband:firstband+nbands-1,:); -lev = pyr(firstind:firstind+sum(prod(ind'))-1); - diff --git a/evaluation/utils/matlabPyrTools/zconv2.m b/evaluation/utils/matlabPyrTools/zconv2.m deleted file mode 100755 index f678d89..0000000 --- a/evaluation/utils/matlabPyrTools/zconv2.m +++ /dev/null @@ -1,41 +0,0 @@ -% RES = ZCONV2(MTX1, MTX2, CTR) -% -% Convolution of two matrices, with boundaries handled as if the larger mtx -% lies in a sea of zeros. Result will be of size of LARGER vector. -% -% The origin of the smaller matrix is assumed to be its center. -% For even dimensions, the origin is determined by the CTR (optional) -% argument: -% CTR origin -% 0 DIM/2 (default) -% 1 (DIM/2)+1 (behaves like conv2(mtx1,mtx2,'same')) - -% Eero Simoncelli, 2/97. - -function c = zconv2(a,b,ctr) - -if (exist('ctr') ~= 1) - ctr = 0; -end - -if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) - large = a; small = b; -elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) - large = b; small = a; -else - error('one arg must be larger than the other in both dimensions!'); -end - -ly = size(large,1); -lx = size(large,2); -sy = size(small,1); -sx = size(small,2); - -%% These values are the index of the small mtx that falls on the -%% border pixel of the large matrix when computing the first -%% convolution response sample: -sy2 = floor((sy+ctr+1)/2); -sx2 = floor((sx+ctr+1)/2); - -clarge = conv2(large,small); -c = clarge(sy2:ly+sy2-1, sx2:lx+sx2-1); diff --git a/evaluation/utils/matlabPyrTools/range2.mexmaci64 b/h5_generator/.DS_Store similarity index 57% rename from evaluation/utils/matlabPyrTools/range2.mexmaci64 rename to h5_generator/.DS_Store index ee259f6..1f045ec 100755 Binary files a/evaluation/utils/matlabPyrTools/range2.mexmaci64 and b/h5_generator/.DS_Store differ diff --git a/h5_generator/gopro_hdf5_generator.m b/h5_generator/gopro_hdf5_generator.m new file mode 100755 index 0000000..45ea39f --- /dev/null +++ b/h5_generator/gopro_hdf5_generator.m @@ -0,0 +1,115 @@ +% ------------------------------------------------------------------------- +% Description: +% A function to generate train hdf5 patches. +% +% Parameter: +% - The download dataset GOPRO_Large's directory +% +% Output: +% - The generated patches are stored in hdf5 files in the directory of +% GOPRO_Large/GOPRO_train256_4x_HDF5. +% +% Citation: +% Gated Fusion Network for Joint Image Deblurring and Super-Resolution +% The British Machine Vision Conference(BMVC2018 oral) +% Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang +% +% Contact: +% cvxinyizhang@gmail.com +% Project Website: +% http://xinyizhang.tech/bmvc2018 +% https://github.com/jacquelinelala/GFN +%% +function gopro_hdf5_generator(folder) + +scale = 4; +size_label = 256; +size_input = size_label/scale; +stride = 128; + +train_folder = fullfile(folder, 'train'); +save_root =fullfile(folder, sprintf('GOPRO_train%d_%dx_HDF5', size_label, scale)); + +if ~isdir(save_root) + mkdir(save_root) +end + +%% generate data +train_sets = dir(fullfile(train_folder,'GO*')); +parts = length(train_sets) +downsizes= [0.5,0.7,1]; +for n=1:parts/2 %n +data = zeros(size_input, size_input, 3, 1); +label_db = zeros(size_input, size_input, 3, 1); +label = zeros(size_label, size_label, 3, 1); +count = 0; +margain = 0; + +for index = (n-1)*2 +1 :n*2 +HR_image_path = fullfile(train_folder, train_sets(index).name, 'sharp') +Blur_image_path = fullfile(train_folder, train_sets(index).name, 'blur_gamma') +filepaths_HR = dir(fullfile(HR_image_path, '0*.png')); +filepaths_BLur = dir(fullfile(Blur_image_path, '0*.png')); + +for i = 1 : length(filepaths_HR) + for downsize = 1:length(downsizes) + image = imread(fullfile(HR_image_path,filepaths_HR(i).name)); + image_Blur = imread(fullfile(Blur_image_path,filepaths_BLur(i).name)); + image = imresize(image,downsizes(downsize),'bicubic'); + image_Blur = imresize(image_Blur,downsizes(downsize),'bicubic'); + if size(image,3)==3 + image = im2double(image); + image_Blur = im2double(image_Blur); + HR_label = modcrop(image, scale); + Blur_label = modcrop(image_Blur, scale); + [hei,wid, c] = size(HR_label); + filepaths_HR(i).name + for x = 1 + margain : stride : hei-size_label+1 - margain + for y = 1 + margain :stride : wid-size_label+1 - margain + %Crop HR patch + HR_patch_label = HR_label(x : x+size_label-1, y : y+size_label-1, :); + [dx,dy] = gradient(HR_patch_label); + gradSum = sqrt(dx.^2 + dy.^2); + gradValue = mean(gradSum(:)); + if gradValue < 0.005 + continue; + end + %Crop Blur patch + Blur_patch_label = Blur_label(x : x+size_label-1, y : y+size_label-1, :); + LR_BLur_input = imresize(Blur_patch_label,1/scale,'bicubic'); + Deblur_label = imresize(HR_patch_label,1/scale,'bicubic'); + count=count+1; + data(:, :, :, count) = LR_BLur_input; + label_db(:, :, :, count) = Deblur_label; + label(:, :, :, count) = HR_patch_label; + end % end of y + end % end of x + end % end of if + end %end of downsize +end % end of i +end % end of index + +order = randperm(count); +data = data(:, :, :, order); +label_db = label_db(:, :, :, order); +label = label(:, :, :, order); + +%% writing to HDF5 +savepath = fullfile(save_root ,sprintf('LR-GOPRO_x4_Part%d.h5', n)) +chunksz = 64; +created_flag = false; +totalct = 0; + +for batchno = 1:floor(count/chunksz) + last_read=(batchno-1)*chunksz; + batchdata = data(:,:,:,last_read+1:last_read+chunksz); + batchlabs_db = label_db(:,:,:,last_read+1:last_read+chunksz); + batchlabs = label(:,:,:,last_read+1:last_read+chunksz); + startloc = struct('dat',[1,1,1,totalct+1], 'lab_db', [1,1,1,totalct+1], 'lab', [1,1,1,totalct+1]); + curr_dat_sz = store2hdf5(savepath, batchdata, batchlabs_db, batchlabs, ~created_flag, startloc, chunksz); + created_flag = true; + totalct = curr_dat_sz(end); +end + +h5disp(savepath); +end % index fo n \ No newline at end of file diff --git a/h5_generator/gopro_val_generator.m b/h5_generator/gopro_val_generator.m new file mode 100755 index 0000000..458228f --- /dev/null +++ b/h5_generator/gopro_val_generator.m @@ -0,0 +1,70 @@ +% ------------------------------------------------------------------------- +% Description: +% A function to generate test dataset: blur_lr input images and hr +% images. +% +% Parameter: +% - The download dataset GOPRO_Large's directory +% +% Output: +% - The generated images are stored in the directory of +% GOPRO_Large/Validation_4x/LR_Blur and GOPRO_Large/Validation_4x/HR +% +% Citation: +% Gated Fusion Network for Joint Image Deblurring and Super-Resolution +% The British Machine Vision Conference(BMVC2018 oral) +% Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang +% +% Contact: +% cvxinyizhang@gmail.com +% Project Website: +% http://xinyizhang.tech/bmvc2018 +% https://github.com/jacquelinelala/GFN + +%% +function gopro_val_generator(folder) +%% scale factors +scale = 4; +test_folder = fullfile(folder,'test'); +blur_root = fullfile(folder, sprintf('Validation_%dx/LR_Blur', scale)); +hr_root = fullfile(folder, sprintf('Validation_%dx/HR', scale)); + +if ~isdir(blur_root) + mkdir(blur_root) +end +if ~isdir(hr_root) + mkdir(hr_root) +end + +%% generate data +val_sets = dir(fullfile(test_folder,'GO*')); +parts = length(val_sets) +name_index = 0; +for n=1:parts +HR_image_path = fullfile(val_sets(n).folder, val_sets(n).name, 'sharp') +Blur_image_path = fullfile(val_sets(n).folder, val_sets(n).name, 'blur_gamma') +filepaths_HR = dir(fullfile(HR_image_path, '0*.png')); +filepaths_BLur = dir(fullfile(Blur_image_path, '0*.png')); + +index = 0; +margain = 0; + +for index = 1 : length(filepaths_HR) + + name_index = name_index + 1; + image = imread(fullfile(filepaths_HR(index).folder,filepaths_HR(index).name)); + image_Blur = imread(fullfile(filepaths_BLur(index).folder,filepaths_BLur(index).name)); + if size(image,3)==3 + image = im2double(image); + image_Blur = im2double(image_Blur); + HR_label1 = modcrop(image, 16);%save + Blur_label1 = modcrop(image_Blur, 16); + filepaths_HR(index).name + %Crop Blur patch + LR_BLur_input = imresize(Blur_label1,1/scale,'bicubic');%save + imwrite(LR_BLur_input, fullfile(blur_root,sprintf('%04d.png',name_index)));%save + imwrite(HR_label1, fullfile(hr_root,sprintf('%04d.png',name_index)));%save + end +end +end + diff --git a/h5_generator/modcrop.m b/h5_generator/modcrop.m new file mode 100755 index 0000000..70db8d2 --- /dev/null +++ b/h5_generator/modcrop.m @@ -0,0 +1,31 @@ +% ------------------------------------------------------------------------- +% Description: +% Make a image get a modulo operation. +% +% Parameter: +% +% Output: +% - A moduloed image. +% +% Citation: +% Gated Fusion Network for Joint Image Deblurring and Super-Resolution +% The British Machine Vision Conference(BMVC2018 oral) +% Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang +% +% Contact: +% cvxinyizhang@gmail.com +% Project Website: +% http://xinyizhang.tech/bmvc2018 +%% +function imgs = modcrop(imgs, modulo) +if size(imgs,3)==1 + sz = size(imgs); + sz = sz - mod(sz, modulo); + imgs = imgs(1:sz(1), 1:sz(2)); +else + tmpsz = size(imgs); + sz = tmpsz(1:2); + sz = sz - mod(sz, modulo); + imgs = imgs(1:sz(1), 1:sz(2),:); +end + diff --git a/h5_generator/store2hdf5.m b/h5_generator/store2hdf5.m new file mode 100755 index 0000000..de5545e --- /dev/null +++ b/h5_generator/store2hdf5.m @@ -0,0 +1,91 @@ +% ------------------------------------------------------------------------- +% Description: +% Store into hdf5 files. +% +% Parameter: +% +% Output: +% - The generated hdf5 files to train. +% +% Citation: +% Gated Fusion Network for Joint Image Deblurring and Super-Resolution +% The British Machine Vision Conference(BMVC2018 oral) +% Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang +% +% Contact: +% cvxinyizhang@gmail.com +% Project Website: +% http://xinyizhang.tech/bmvc2018 +%% +function [curr_dat_sz, curr_lab_db_sz, curr_lab_sz] = store2hdf5(filename, data, labels_db, labels, create, startloc, chunksz) + % *data* is W*H*C*N matrix of images should be normalized (e.g. to lie between 0 and 1) beforehand + % *label* is D*N matrix of labels (D labels per sample) + % *create* [0/1] specifies whether to create file newly or to append to previously created file, useful to store information in batches when a dataset is too big to be held in memory (default: 1) + % *startloc* (point at which to start writing data). By default, + % if create=1 (create mode), startloc.data=[1 1 1 1], and startloc.lab=[1 1]; + % if create=0 (append mode), startloc.data=[1 1 1 K+1], and startloc.lab = [1 K+1]; where K is the current number of samples stored in the HDF + % chunksz (used only in create mode), specifies number of samples to be stored per chunk (see HDF5 documentation on chunking) for creating HDF5 files with unbounded maximum size - TLDR; higher chunk sizes allow faster read-write operations + + % verify that format is right + dat_dims=size(data); + lab_db_dims=size(labels_db); + lab_dims=size(labels); + num_samples=dat_dims(end); + + assert(lab_dims(end)==num_samples, 'Number of samples should be matched between data and labels'); + assert(lab_db_dims(end)==num_samples, 'Number of samples should be matched between data and labels'); + + + if ~exist('create','var') + create=true; + end + + + if create + %fprintf('Creating dataset with %d samples\n', num_samples); + if ~exist('chunksz', 'var') + chunksz=1000; + end + if exist(filename, 'file') + fprintf('Warning: replacing existing file %s \n', filename); + delete(filename); + end + + h5create(filename, '/data', [dat_dims(1:end-1) Inf], 'Datatype', 'single', 'ChunkSize', [dat_dims(1:end-1) chunksz]); % width, height, channels, number + h5create(filename, '/label_db', [lab_db_dims(1:end-1) Inf], 'Datatype', 'single', 'ChunkSize', [lab_db_dims(1:end-1) chunksz]); % width, height, channels, number + h5create(filename, '/label', [lab_dims(1:end-1) Inf], 'Datatype', 'single', 'ChunkSize', [lab_dims(1:end-1) chunksz]); % width, height, channels, number + if ~exist('startloc','var') + startloc.dat=[ones(1,length(dat_dims)-1), 1]; + startloc.lab_db=[ones(1,length(lab_db_dims)-1), 1]; + startloc.lab=[ones(1,length(lab_dims)-1), 1]; + end + + else % append mode + if ~exist('startloc','var') + info=h5info(filename); + prev_dat_sz=info.Datasets(1).Dataspace.Size; + prev_lab_db_sz=info.Datasets(2).Dataspace.Size; + prev_lab_sz=info.Datasets(3).Dataspace.Size; + + assert(prev_dat_sz(1:end-1)==dat_dims(1:end-1), 'Data dimensions must match existing dimensions in dataset'); + assert(prev_lab_db_sz(1:end-1)==lab_db_dims(1:end-1), 'Label_db dimensions must match existing dimensions in dataset'); + assert(prev_lab_sz(1:end-1)==lab_dims(1:end-1), 'Label dimensions must match existing dimensions in dataset'); + startloc.dat=[ones(1,length(dat_dims)-1), prev_dat_sz(end)+1]; + startloc.lab_db=[ones(1,length(lab_db_dims)-1), prev_lab_db_sz(end)+1]; + startloc.lab=[ones(1,length(lab_dims)-1), prev_lab_sz(end)+1]; + end + end + + if ~isempty(data) + h5write(filename, '/data', single(data), startloc.dat, size(data)); + h5write(filename, '/label_db', single(labels_db), startloc.lab_db, size(labels_db)); + h5write(filename, '/label', single(labels), startloc.lab, size(labels)); + end + + if nargout + info=h5info(filename); + curr_dat_sz=info.Datasets(1).Dataspace.Size; + curr_lab_db_sz=info.Datasets(2).Dataspace.Size; + curr_lab_sz=info.Datasets(3).Dataspace.Size; + end +end diff --git a/models/.DS_Store b/models/.DS_Store index 5008ddf..899289e 100755 Binary files a/models/.DS_Store and b/models/.DS_Store differ diff --git a/networks/.DS_Store b/networks/.DS_Store index 8dfdff2..b4d6336 100755 Binary files a/networks/.DS_Store and b/networks/.DS_Store differ diff --git a/networks/GFN_4x.py b/networks/GFN_4x.py new file mode 100755 index 0000000..0b1c736 --- /dev/null +++ b/networks/GFN_4x.py @@ -0,0 +1,229 @@ +import torch +import torch.nn as nn +import math +import torch.nn.init as init +import os + +class _ResBLockDB(nn.Module): + def __init__(self, inchannel, outchannel, stride=1): + super(_ResBLockDB, self).__init__() + self.layers = nn.Sequential( + nn.Conv2d(inchannel, outchannel, 3, stride, 1, bias=True), + nn.ReLU(inplace=True), + nn.Conv2d(outchannel, outchannel, 3, stride, 1, bias=True) + ) + for i in self.modules(): + if isinstance(i, nn.Conv2d): + j = i.kernel_size[0] * i.kernel_size[1] * i.out_channels + i.weight.data.normal_(0, math.sqrt(2 / j)) + if i.bias is not None: + i.bias.data.zero_() + + def forward(self, x): + out = self.layers(x) + residual = x + out = torch.add(residual, out) + return out + +class _ResBlockSR(nn.Module): + def __init__(self, inchannel, outchannel, stride=1): + super(_ResBlockSR, self).__init__() + self.layers = nn.Sequential( + nn.Conv2d(inchannel, outchannel, 3, stride, 1, bias=True), + nn.LeakyReLU(0.2, inplace=True), + nn.Conv2d(outchannel, outchannel, 3, stride, 1, bias=True) + ) + for i in self.modules(): + if isinstance(i, nn.Conv2d): + j = i.kernel_size[0] * i.kernel_size[1] * i.out_channels + i.weight.data.normal_(0, math.sqrt(2 / j)) + if i.bias is not None: + i.bias.data.zero_() + + def forward(self, x): + out = self.layers(x) + residual = x + out = torch.add(residual, out) + return out + +class _DeblurringMoudle(nn.Module): + def __init__(self): + super(_DeblurringMoudle, self).__init__() + self.conv1 = nn.Conv2d(3, 64, (7, 7), 1, padding=3) + self.relu = nn.LeakyReLU(0.2, inplace=True) + self.resBlock1 = self._makelayers(64, 64, 6) + self.conv2 = nn.Sequential( + nn.Conv2d(64, 128, (3, 3), 2, 1), + nn.ReLU(inplace=True) + ) + self.resBlock2 = self._makelayers(128, 128, 6) + self.conv3 = nn.Sequential( + nn.Conv2d(128, 256, (3, 3), 2, 1), + nn.ReLU(inplace=True) + ) + self.resBlock3 = self._makelayers(256, 256, 6) + self.deconv1 = nn.Sequential( + nn.ConvTranspose2d(256, 128, (4, 4), 2, padding=1), + nn.ReLU(inplace=True) + ) + self.deconv2 = nn.Sequential( + nn.ConvTranspose2d(128, 64, (4, 4), 2, padding=1), + nn.ReLU(inplace=True), + nn.Conv2d(64, 64, (7, 7), 1, padding=3) + ) + self.convout = nn.Sequential( + nn.Conv2d(64, 64, (3, 3), 1, 1), + nn.ReLU(inplace=True), + nn.Conv2d(64, 3, (3, 3), 1, 1) + ) + for i in self.modules(): + if isinstance(i, nn.Conv2d): + j = i.kernel_size[0] * i.kernel_size[1] * i.out_channels + i.weight.data.normal_(0, math.sqrt(2 / j)) + if i.bias is not None: + i.bias.data.zero_() + + def _makelayers(self, inchannel, outchannel, block_num, stride=1): + layers = [] + for i in range(0, block_num): + layers.append(_ResBLockDB(inchannel, outchannel)) + return nn.Sequential(*layers) + + def forward(self, x): + con1 = self.relu(self.conv1(x)) + res1 = self.resBlock1(con1) + res1 = torch.add(res1, con1) + con2 = self.conv2(res1) + res2 = self.resBlock2(con2) + res2 = torch.add(res2, con2) + con3 = self.conv3(res2) + res3 = self.resBlock3(con3) + res3 = torch.add(res3, con3) + decon1 = self.deconv1(res3) + deblur_feature = self.deconv2(decon1) + deblur_out = self.convout(torch.add(deblur_feature, con1)) + return deblur_feature, deblur_out + +class _SRMoudle(nn.Module): + def __init__(self): + super(_SRMoudle, self).__init__() + self.conv1 = nn.Conv2d(3, 64, (7, 7), 1, padding=3) + self.relu = nn.LeakyReLU(0.2, inplace=True) + self.resBlock = self._makelayers(64, 64, 8, 1) + self.conv2 = nn.Conv2d(64, 64, (3, 3), 1, 1) + + for i in self.modules(): + if isinstance(i, nn.Conv2d): + j = i.kernel_size[0] * i.kernel_size[1] * i.out_channels + i.weight.data.normal_(0, math.sqrt(2 / j)) + if i.bias is not None: + i.bias.data.zero_() + + def _makelayers(self, inchannel, outchannel, block_num, stride=1): + layers = [] + for i in range(0, block_num): + layers.append(_ResBlockSR(inchannel, outchannel)) + return nn.Sequential(*layers) + + def forward(self, x): + con1 = self.relu(self.conv1(x)) + res1 = self.resBlock(con1) + con2 = self.conv2(res1) + sr_feature = torch.add(con2, con1) + return sr_feature + +class _GateMoudle(nn.Module): + def __init__(self): + super(_GateMoudle, self).__init__() + + self.conv1 = nn.Conv2d(131, 64, (3, 3), 1, 1) + self.relu = nn.LeakyReLU(0.2, inplace=True) + self.conv2 = nn.Conv2d(64, 64, (1, 1), 1, padding=0) + + for i in self.modules(): + if isinstance(i, nn.Conv2d): + j = i.kernel_size[0] * i.kernel_size[1] * i.out_channels + i.weight.data.normal_(0, math.sqrt(2 / j)) + if i.bias is not None: + i.bias.data.zero_() + + def forward(self, x): + con1 = self.relu(self.conv1(x)) + scoremap = self.conv2(con1) + return scoremap + +class _ReconstructMoudle(nn.Module): + def __init__(self): + super(_ReconstructMoudle, self).__init__() + self.resBlock = self._makelayers(64, 64, 8) + self.conv1 = nn.Conv2d(64, 256, (3, 3), 1, 1) + self.pixelShuffle1 = nn.PixelShuffle(2) + self.relu1 = nn.LeakyReLU(0.1, inplace=True) + self.conv2 = nn.Conv2d(64, 256, (3, 3), 1, 1) + self.pixelShuffle2 = nn.PixelShuffle(2) + self.relu2 = nn.LeakyReLU(0.2, inplace=True) + self.conv3 = nn.Conv2d(64, 64, (3, 3), 1, 1) + self.relu3 = nn.LeakyReLU(0.2, inplace=True) + self.conv4 = nn.Conv2d(64, 3, (3, 3), 1, 1) + + for i in self.modules(): + if isinstance(i, nn.Conv2d): + j = i.kernel_size[0] * i.kernel_size[1] * i.out_channels + i.weight.data.normal_(0, math.sqrt(2 / j)) + if i.bias is not None: + i.bias.data.zero_() + + def _makelayers(self, inchannel, outchannel, block_num, stride=1): + layers = [] + for i in range(0, block_num): + layers.append(_ResBLockDB(inchannel, outchannel)) + return nn.Sequential(*layers) + + def forward(self, x): + res1 = self.resBlock(x) + con1 = self.conv1(res1) + pixelshuffle1 = self.relu1(self.pixelShuffle1(con1)) + con2 = self.conv2(pixelshuffle1) + pixelshuffle2 = self.relu2(self.pixelShuffle2(con2)) + con3 = self.relu3(self.conv3(pixelshuffle2)) + sr_deblur = self.conv4(con3) + return sr_deblur + +class Net(nn.Module): + def __init__(self): + super(Net, self).__init__() + self.deblurMoudle = self._make_net(_DeblurringMoudle) + self.srMoudle = self._make_net(_SRMoudle) + self.geteMoudle = self._make_net(_GateMoudle) + self.reconstructMoudle = self._make_net(_ReconstructMoudle) + + def forward(self, x, gated, isTest): + if isTest == True: + origin_size = x.size() + input_size = (math.ceil(origin_size[2]/4)*4, math.ceil(origin_size[3]/4)*4) + out_size = (origin_size[2]*4, origin_size[3]*4) + x = nn.functional.upsample(x, size=input_size, mode='bilinear') + + deblur_feature, deblur_out = self.deblurMoudle(x) + sr_feature = self.srMoudle(x) + if gated == True: + scoremap = self.geteMoudle(torch.cat((deblur_feature, x, sr_feature), 1)) + else: + scoremap = torch.cuda.FloatTensor().resize_(sr_feature.shape).zero_()+1 + repair_feature = torch.mul(scoremap, deblur_feature) + fusion_feature = torch.add(sr_feature, repair_feature) + recon_out = self.reconstructMoudle(fusion_feature) + + if isTest == True: + recon_out = nn.functional.upsample(recon_out, size=out_size, mode='bilinear') + + return deblur_out, recon_out + + def _make_net(self, net): + nets = [] + nets.append(net()) + return nn.Sequential(*nets) + + + + diff --git a/networks/GFN_x4.py b/networks/GFN_x4.py deleted file mode 100755 index 7a69e99..0000000 --- a/networks/GFN_x4.py +++ /dev/null @@ -1,187 +0,0 @@ -import torch -import torch.nn as nn -import math -import torch.nn.init as init - - -class _Residual_Block_DB(nn.Module): - def __init__(self, num_ft): - super(_Residual_Block_DB, self).__init__() - - self.conv1 = nn.Conv2d(in_channels=num_ft, out_channels=num_ft, kernel_size=3, stride=1, padding=1, bias=True) - self.relu = nn.ReLU(inplace=True) - self.conv2 = nn.Conv2d(in_channels=num_ft, out_channels=num_ft, kernel_size=3, stride=1, padding=1, bias=True) - - def forward(self, x): - identity_data = x - output = self.relu(self.conv1(x)) - output = self.conv2(output) - output = torch.add(output, identity_data) - return output - -class _Residual_Block_SR(nn.Module): - def __init__(self): - super(_Residual_Block_SR, self).__init__() - - self.conv1 = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1, padding=1, bias=True) - self.relu = nn.LeakyReLU(0.2, inplace=True) - self.conv2 = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1, padding=1, bias=True) - - def forward(self, x): - identity_data = x - output = self.relu(self.conv1(x)) - output = self.conv2(output) - output = torch.add(output, identity_data) - return output - - -class _EDNet(nn.Module): - def __init__(self): - super(_EDNet, self).__init__() - - self.conv_input = nn.Conv2d(in_channels=3, out_channels=64, kernel_size=7, stride=1, padding=3, bias=True) - self.relu = nn.LeakyReLU(0.2, inplace=True) - - self.residual_db = self.make_layer(_Residual_Block_DB, 6, 64) - - self.conv_stride1 = nn.Sequential( - nn.Conv2d(in_channels=64, out_channels=128, kernel_size=3, stride=2, padding=1, bias=True), - nn.ReLU(inplace=True) - ) - self.residual_db1 = self.make_layer(_Residual_Block_DB, 6, 128) - - self.conv_stride2 = nn.Sequential( - nn.Conv2d(in_channels=128, out_channels=256, kernel_size=3, stride=2, padding=1, bias=True), - nn.ReLU(inplace=True) - ) - - self.residual_db2 = self.make_layer(_Residual_Block_DB, 6, 256) - - self.deconv2 = nn.Sequential( - nn.ConvTranspose2d(in_channels=256, out_channels=128, kernel_size=4, stride=2, padding=1, bias=True), - nn.ReLU(), - ) - - self.deconv1 = nn.Sequential( - nn.ConvTranspose2d(in_channels=128, out_channels=64, kernel_size=4, stride=2, padding=1, bias=True), - nn.ReLU(), - nn.Conv2d(in_channels=64, out_channels=64, kernel_size=7, stride=1, padding=3, bias=True) - ) - - self.conv_out = nn.Sequential( - nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1, padding=1, bias=True), - nn.ReLU(), - nn.Conv2d(in_channels=64, out_channels=3, kernel_size=3, stride=1, padding=1, bias=True) - ) - - for m in self.modules(): - if isinstance(m, nn.Conv2d): - n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels - m.weight.data.normal_(0, math.sqrt(2. / n)) - if m.bias is not None: - m.bias.data.zero_() - elif isinstance(m, nn.BatchNorm2d): - m.weight.data.fill_(1) - if m.bias is not None: - m.bias.data.zero_() - - def make_layer(self, block, num_of_layer, num_ft): - layers = [] - for _ in range(num_of_layer): - layers.append(block(num_ft)) - return nn.Sequential(*layers) - - def forward(self, x): - out = self.conv_input(x) - res1 = out - out = self.residual_db(out) - out = torch.add(out, res1) - out = self.conv_stride1(out) - residual1 = out - out = self.residual_db1(out) - out = torch.add(out, residual1) - out = self.conv_stride2(out) - residual2 = out - out = self.residual_db2(out) - out = torch.add(out, residual2) - out = self.deconv2(out) - out = self.deconv1(out) - res_ft = out - out = torch.add(out, res1) - out = self.conv_out(out) - return res_ft, out - - -class Net(nn.Module): - def __init__(self): - super(Net, self).__init__() - - self.conv_input = nn.Conv2d(in_channels=3, out_channels=64, kernel_size=9, stride=1, padding=4, bias=True) - self.relu = nn.LeakyReLU(0.2, inplace=True) - - self.residual1 = self.make_layer(_Residual_Block_SR, 8) - self.residual2 = self.make_layer(_Residual_Block_SR, 8) - - self.conv_mid = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1, padding=1, bias=True) - - self.upscale4x = nn.Sequential( - nn.Conv2d(in_channels=64, out_channels=256, kernel_size=3, stride=1, padding=1, bias=True), - nn.PixelShuffle(2), - nn.LeakyReLU(0.2, inplace=True), - nn.Conv2d(in_channels=64, out_channels=256, kernel_size=3, stride=1, padding=1, bias=True), - nn.PixelShuffle(2), - nn.LeakyReLU(0.2, inplace=True), - ) - - self.conv_output = nn.Sequential( - nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1)), # eliminate the artifacts - nn.LeakyReLU(0.2, inplace=True), - nn.Conv2d(64, 3, (3, 3), (1, 1), (1, 1)) - ) - - self.ednet = self.make_layer(_EDNet, 1) - - ##############Attention Model##################### - self.attention_model = nn.Sequential( - nn.Conv2d(in_channels=131, out_channels=64, kernel_size=3, stride=1, padding=1, bias=True), - nn.LeakyReLU(0.2, inplace=True), - nn.Conv2d(in_channels=64, out_channels=64, kernel_size=1, stride=1, padding=0, bias=True), - ) - - for m in self.modules(): - if isinstance(m, nn.Conv2d): - n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels - m.weight.data.normal_(0, math.sqrt(2. / n)) - if m.bias is not None: - m.bias.data.zero_() - elif isinstance(m, nn.BatchNorm2d): - m.weight.data.fill_(1) - if m.bias is not None: - m.bias.data.zero_() - - def make_layer(self, block, num_of_layer): - layers = [] - for _ in range(num_of_layer): - layers.append(block()) - return nn.Sequential(*layers) - - def forward(self, x): - [detail_ft, lr_deblur] = self.ednet(x) - att_in1 = detail_ft - - out = self.conv_input(x) - residual = out - out = self.residual1(out) - out = self.conv_mid(out) - out = torch.add(out, residual) - att_in2 = out - att_in = torch.cat((x,att_in1, att_in2), dim=1) - scoremap = self.attention_model(att_in) - detail_ft = torch.mul(detail_ft, scoremap) - - out = torch.add(out, detail_ft) - - out = self.residual2(out) - out = self.upscale4x(out) - sr = self.conv_output(out) - return lr_deblur, scoremap, sr \ No newline at end of file diff --git a/test_GFN_4x.py b/test_GFN_4x.py new file mode 100755 index 0000000..894d52d --- /dev/null +++ b/test_GFN_4x.py @@ -0,0 +1,133 @@ +# Citation: +# Gated Fusion Network for Joint Image Deblurring and Super-Resolution +# The British Machine Vision Conference(BMVC2018 oral) +# Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang +# Contact: +# cvxinyizhang@gmail.com +# Project Website: +# http://xinyizhang.tech/bmvc2018 +# https://github.com/jacquelinelala/GFN + +from __future__ import print_function +import argparse +import os +import time +from math import log10 +from os.path import join +from torchvision import transforms +from torchvision import utils as utils +import torch +from torch.utils.data import DataLoader +from datasets.dataset_hf5 import DataValSet +import statistics +import matplotlib.pyplot as plot +import re + +parser = argparse.ArgumentParser(description="PyTorch LapSRN Test") +parser.add_argument("--scale", default=4, type=int, help="scale factor, Default: 4") +parser.add_argument("--gated", type=bool, default=True, help="Activated gate module") +parser.add_argument("--isTest", type=bool, default=True, help="Test or not") +parser.add_argument('--dataset', required=True, help='Path of the validation dataset') +parser.add_argument("--intermediate_process", default="", type=str, help="Test on intermediate pkl (default: none)") +os.environ['CUDA_VISIBLE_DEVICES'] = '1' +device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + +test_set=[ + {'gated':False}, + {'gated':False}, + {'gated':True} +] + +def is_pkl(filename): + return any(filename.endswith(extension) for extension in [".pkl"]) + +def which_trainingstep_epoch(resume): + trainingstep = "".join(re.findall(r"\d", resume)[0]) + start_epoch = "".join(re.findall(r"\d", resume)[1:]) + return int(trainingstep), int(start_epoch) + +def displayFeature(feature): + feat_permute = feature.permute(1, 0, 2, 3) + grid = utils.make_grid(feat_permute.cpu(), nrow=16, normalize=True, padding=10) + grid = grid.numpy().transpose((1, 2, 0)) + display_grid = grid[:, :, 0] + plot.imshow(display_grid) + +def test(test_gen, model, criterion, SR_dir): + avg_psnr = 0 + med_time = [] + + with torch.no_grad(): + for iteration, batch in enumerate(test_gen, 1): + LR_Blur = batch[0] + HR = batch[1] + LR_Blur = LR_Blur.to(device) + HR = HR.to(device) + + if opt.isTest == True: + test_Tensor = torch.cuda.FloatTensor().resize_(1).zero_() + 1 + else: + test_Tensor = torch.cuda.FloatTensor().resize_(1).zero_() + if opt.gated == True: + gated_Tensor = torch.cuda.FloatTensor().resize_(1).zero_() + 1 + else: + gated_Tensor = torch.cuda.FloatTensor().resize_(1).zero_() + + start_time = time.perf_counter()#-------------------------begin to deal with an image's time + [lr_deblur, sr] = model(LR_Blur, gated_Tensor, test_Tensor) + #modify + sr = torch.clamp(sr, min=0, max=1) + torch.cuda.synchronize()#wait for CPU & GPU time syn + evalation_time = time.perf_counter() - start_time#---------finish an image + med_time.append(evalation_time) + + resultSRDeblur = transforms.ToPILImage()(sr.cpu()[0]) + resultSRDeblur.save(join(SR_dir, '{0:04d}_GFN_4x.png'.format(iteration))) + print("Processing {}".format(iteration)) + mse = criterion(sr, HR) + psnr = 10 * log10(1 / mse) + avg_psnr += psnr + + print("Avg. SR PSNR:{:4f} dB".format(avg_psnr / iteration)) + median_time = statistics.median(med_time) + print(median_time) + +def model_test(model): + model = model.to(device) + criterion = torch.nn.MSELoss(size_average=True) + criterion = criterion.to(device) + print(opt) + test(testloader, model, criterion, SR_dir) + +opt = parser.parse_args() +root_val_dir = opt.dataset# #----------Validation path +SR_dir = join(root_val_dir, 'Results') #--------------------------SR results save path +isexists = os.path.exists(SR_dir) +if not isexists: + os.makedirs(SR_dir) +print("The results of testing images sotre in {}.".format(SR_dir)) + +testloader = DataLoader(DataValSet(root_val_dir), batch_size=1, shuffle=False, pin_memory=False) +print("===> Loading model and criterion") + +if opt.intermediate_process: + test_pkl = opt.intermediate_process + if is_pkl(test_pkl): + print("Testing model {}----------------------------------".format(opt.intermediate_process)) + train_step, epoch = which_trainingstep_epoch(opt.intermediate_process) + opt.gated = test_set[train_step-1]['gated'] + model = torch.load(test_pkl) + model_test(model) + else: + print("It's not a pkl file. Please give a correct pkl folder on command line for example --opt.intermediate_process /models/1/GFN_epoch_25.pkl)") +else: + test_dir = 'models/' + test_list = [x for x in sorted(os.listdir(test_dir)) if is_pkl(x)] + print("Testing on the given 3-step trained model which stores in /models, and ends with pkl.") + for i in range(len(test_list)): + print("Testing model is {}----------------------------------".format(test_list[i])) + model = torch.load(join(test_dir, test_list[i])) + model_test(model) + + + diff --git a/test_GFN_x4.py b/test_GFN_x4.py deleted file mode 100755 index 8226a93..0000000 --- a/test_GFN_x4.py +++ /dev/null @@ -1,90 +0,0 @@ -from __future__ import print_function - -import argparse -import os -import time -from math import log10 -from os.path import join -import numpy as np -from torchvision import transforms -import torch -from torch.utils.data import DataLoader -from datasets.dataset_hf5 import DataValSet -import statistics - -# Training settings -model_sets = {'GFN_4x':'models/GFN_4x.pth'} -modelName = 'GFN_4x' - -# Training settings -parser = argparse.ArgumentParser(description="PyTorch LapSRN Test") -parser.add_argument("--cuda", action="store_true", help="use cuda?") -parser.add_argument("--model", default=model_sets[modelName], type=str, help="model path") -parser.add_argument("--scale", default=4, type=int, help="scale factor, Default: 4") -os.environ['CUDA_VISIBLE_DEVICES'] = '0' -device = torch.device("cuda" if torch.cuda.is_available() else "cpu") - -def test(test_gen, model, criterion, SR_dir): - avg_psnr = 0 - med_time = [] - - with torch.no_grad(): - for iteration, batch in enumerate(test_gen, 1): - LR_Blur = batch[0] - LR_Deblur = batch[1] - HR = batch[2] - names = batch[3] - - LR_Blur = LR_Blur.to(device) - LR_Deblur = LR_Deblur.to(device) - HR = HR.to(device) - - start_time = time.perf_counter()#-------------------------begin to deal with an image's time - [lr_deblur, scoremap, sr] = model(LR_Blur) - #modify - im_l = lr_deblur.cpu().numpy() - im_l[im_l < 0] = 0 - im_l[im_l > 1] = 1 - im_h = sr.cpu().numpy() - im_h[im_h < 0] = 0 - im_h[im_h > 1] = 1 - torch.cuda.synchronize()#wait for CPU & GPU time syn - evalation_time = time.perf_counter() - start_time#---------finish an image - med_time.append(evalation_time) - - - lr_tensor = torch.from_numpy(np.asarray(im_l, np.float32)) - sr_tensor = torch.from_numpy(np.asarray(im_h, np.float32)) - - resultSRDeblur = transforms.ToPILImage()(sr_tensor[0]) - resultSRDeblur.save(join(SR_dir, '{0:04d}_GFN_4x.png'.format(iteration))) - LR = lr_tensor.to(device) - SR = sr_tensor.to(device) - - mse = criterion(SR, HR) - psnr = 10 * log10(1 / mse) - avg_psnr += psnr - print(iteration) - - print("===>Avg. SR PSNR:{:4f} dB".format(avg_psnr / iteration)) - median_time = statistics.median(med_time) - print(median_time) - -opt = parser.parse_args() -print(opt) - -print("===> Loading datasets") -root_val_dir = '/4TB/datasets/LR-GOPRO/Validation_4x' #----------Validation path -SR_dir = join(root_val_dir, 'Results') #--------------------------SR results save path -print(SR_dir) -testloader = DataLoader(DataValSet(root_val_dir), batch_size=1, shuffle=False, pin_memory=False) -print("===> Loading model and criterion") -print(opt.model) -model = torch.load(opt.model, map_location=lambda storage, loc: storage)["model"] -model = model.to(device) -criterion = torch.nn.MSELoss(size_average=True) -criterion = criterion.to(device) - -test(testloader, model, criterion, SR_dir) - - diff --git a/train_GFN_4x.py b/train_GFN_4x.py new file mode 100755 index 0000000..f2a40ec --- /dev/null +++ b/train_GFN_4x.py @@ -0,0 +1,151 @@ +# Citation: +# Gated Fusion Network for Joint Image Deblurring and Super-Resolution +# The British Machine Vision Conference(BMVC2018 oral) +# Xinyi Zhang, Hang Dong, Zhe Hu, Wei-Sheng Lai, Fei Wang and Ming-Hsuan Yang +# Contact: +# cvxinyizhang@gmail.com +# Project Website: +# http://xinyizhang.tech/bmvc2018 +# https://github.com/jacquelinelala/GFN + +from __future__ import print_function +import torch.optim as optim +import argparse +import os +from os.path import join +import torch +from torch.utils.data import DataLoader +from datasets.dataset_hf5 import DataSet +from networks.GFN_4x import Net +import random +import re + +# Training settings +parser = argparse.ArgumentParser(description="PyTorch Train") +parser.add_argument("--batchSize", type=int, default=16, help="Training batch size") +parser.add_argument("--start_training_step", type=int, default=1, help="Training step") +parser.add_argument("--nEpochs", type=int, default=60, help="Number of epochs to train") +parser.add_argument("--lr", type=float, default=1e-4, help="Learning rate, default=1e-4") +parser.add_argument("--step", type=int, default=7, help="Change the learning rate for every 30 epochs") +parser.add_argument("--start-epoch", type=int, default=1, help="Start epoch from 1") +parser.add_argument("--lr_decay", type=float, default=0.5, help="Decay scale of learning rate, default=0.5") +parser.add_argument("--resume", default="", type=str, help="Path to checkpoint (default: none)") +parser.add_argument("--scale", default=4, type=int, help="Scale factor, Default: 4") +parser.add_argument("--lambda_db", type=float, default=0.5, help="Weight of deblurring loss, default=0.5") +parser.add_argument("--gated", type=bool, default=False, help="Activated gate module") +parser.add_argument("--isTest", type=bool, default=False, help="Test or not") +parser.add_argument('--dataset', required=True, help='Path of the training dataset(.h5)') +os.environ['CUDA_VISIBLE_DEVICES'] = '1' +device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + +training_settings=[ + {'nEpochs': 25, 'lr': 1e-4, 'step': 7, 'lr_decay': 0.5, 'lambda_db': 0.5, 'gated': False}, + {'nEpochs': 60, 'lr': 1e-4, 'step': 30, 'lr_decay': 0.1, 'lambda_db': 0.5, 'gated': False}, + {'nEpochs': 55, 'lr': 5e-5, 'step': 25, 'lr_decay': 0.1, 'lambda_db': 0, 'gated': True} +] + +def mkdir_steptraing(): + root_folder = os.path.abspath('.') + models_folder = join(root_folder, 'models') + step1_folder, step2_folder, step3_folder = join(models_folder,'1'), join(models_folder,'2'), join(models_folder, '3') + isexists = os.path.exists(step1_folder) and os.path.exists(step2_folder) and os.path.exists(step3_folder) + if not isexists: + os.makedirs(step1_folder) + os.makedirs(step2_folder) + os.makedirs(step3_folder) + print("===> Step training models store in models/1 & /2 & /3.") + +def is_hdf5_file(filename): + return any(filename.endswith(extension) for extension in [".h5"]) + +def which_trainingstep_epoch(resume): + trainingstep = "".join(re.findall(r"\d", resume)[0]) + start_epoch = "".join(re.findall(r"\d", resume)[1:]) + return int(trainingstep), int(start_epoch) + +def adjust_learning_rate(epoch): + lr = opt.lr * (opt.lr_decay ** (epoch // opt.step)) + print(lr) + for param_group in optimizer.param_groups: + param_group['lr'] = lr + +def checkpoint(step, epoch): + model_out_path = "models/{}/GFN_epoch_{}.pkl".format(step, epoch) + torch.save(model, model_out_path) + print("===>Checkpoint saved to {}".format(model_out_path)) + +def train(train_gen, model, criterion, optimizer, epoch): + epoch_loss = 0 + for iteration, batch in enumerate(train_gen, 1): + #input, targetdeblur, targetsr + LR_Blur = batch[0] + LR_Deblur = batch[1] + HR = batch[2] + LR_Blur = LR_Blur.to(device) + LR_Deblur = LR_Deblur.to(device) + HR = HR.to(device) + + if opt.isTest == True: + test_Tensor = torch.cuda.FloatTensor().resize_(1).zero_()+1 + else: + test_Tensor = torch.cuda.FloatTensor().resize_(1).zero_() + if opt.gated == True: + gated_Tensor = torch.cuda.FloatTensor().resize_(1).zero_()+1 + else: + gated_Tensor = torch.cuda.FloatTensor().resize_(1).zero_() + + [lr_deblur, sr] = model(LR_Blur, gated_Tensor, test_Tensor) + + loss1 = criterion(lr_deblur, LR_Deblur) + loss2 = criterion(sr, HR) + mse = loss2 + opt.lambda_db * loss1 + epoch_loss += mse + optimizer.zero_grad() + mse.backward() + optimizer.step() + if iteration % 100 == 0: + print("===> Epoch[{}]({}/{}): Loss{:.4f};".format(epoch, iteration, len(trainloader), mse.cpu())) + print("===>Epoch{} Complete: Avg loss is :{:4f}".format(epoch, epoch_loss / len(trainloader))) + +opt = parser.parse_args() +opt.seed = random.randint(1, 10000) +torch.manual_seed(opt.seed) +torch.cuda.manual_seed(opt.seed) + +train_dir = opt.dataset +train_sets = [x for x in sorted(os.listdir(train_dir)) if is_hdf5_file(x)] +print("===> Loading model and criterion") + +if opt.resume: + if os.path.isfile(opt.resume): + print("Loading from checkpoint {}".format(opt.resume)) + model = torch.load(opt.resume) + model.load_state_dict(model.state_dict()) + opt.start_training_step, opt.start_epoch = which_trainingstep_epoch(opt.resume) +else: + model = Net() + mkdir_steptraing() + +model = model.to(device) +criterion = torch.nn.MSELoss(size_average=True) +criterion = criterion.to(device) +optimizer = optim.Adam(model.parameters(), lr=opt.lr) +print() + +for i in range(opt.start_training_step, 4): + opt.nEpochs = training_settings[i-1]['nEpochs'] + opt.lr = training_settings[i-1]['lr'] + opt.step = training_settings[i-1]['step'] + opt.lr_decay = training_settings[i-1]['lr_decay'] + opt.lambda_db = training_settings[i-1]['lambda_db'] + opt.gated = training_settings[i-1]['gated'] + print(opt) + for epoch in range(opt.start_epoch, opt.nEpochs+1): + adjust_learning_rate(epoch-1) + random.shuffle(train_sets) + for j in range(len(train_sets)): + print("Step {}:Training folder is {}-------------------------------".format(i, train_sets[j])) + train_set = DataSet(join(train_dir, train_sets[j])) + trainloader = DataLoader(dataset=train_set, batch_size=opt.batchSize, shuffle=True, num_workers=1) + train(trainloader, model, criterion, optimizer, epoch) + checkpoint(i, epoch) \ No newline at end of file