UPDOWNSAMPLE_FOURIER.m upsamples DS-KCF models in the Fourier Domain UPDOWNSAMPLE_FOURIER is a function for upsampling DS-KCF model in the Fourier Domain. This operation is fundamental for the DS-KCF tracker as described in [1]. This function was implemented by using the function "updownsample" presented by Ohad Gal and shared in the Matlab Central at this link under BSD licence http://uk.mathworks.com/matlabcentral/fileexchange/4658-updownsample input: in_m - input matrix for up/down sampling. can be in space domain OR in fourier domain, in such case, needs to be in matlab format !!! (matlab-format = the save as given from fft/fft2) out_x_sz,out_y_sz - desired number of pixels in the output image is_fourier_flag - 1: the input is given in the fourier domain 0: the input is given in the space domain (we need to use fft2 to convert to fourier domain) is_real_flag - 0: the input is a complex matrix -> don't use abs() at the output, perform complex up/down sampling 1: the input is real BUT has negative values -> use real() at the output 2: the input is real and positive -> using abs() at the output output: out_m - up/down sampled image See also MODELUPDATEDSKCF [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T. Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D data, Journal of Real-Time Image Processing University of Bristol Massimo Camplani and Sion Hannuna massimo.camplani@bristol.ac.uk hannuna@compsci.bristol.ac.uk
0001 function out_m = updownsample_fourier_leave_gain( in_m,out_x_sz,out_y_sz, padded_out_m ) 0002 % UPDOWNSAMPLE_FOURIER.m upsamples DS-KCF models in the Fourier Domain 0003 % 0004 % UPDOWNSAMPLE_FOURIER is a function for upsampling DS-KCF model in the 0005 % Fourier Domain. This operation is fundamental for the DS-KCF tracker as 0006 % described in [1]. This function was implemented by using the function 0007 % "updownsample" presented by Ohad Gal and shared in the Matlab Central 0008 % at this link under BSD licence 0009 % http://uk.mathworks.com/matlabcentral/fileexchange/4658-updownsample 0010 % 0011 % input: in_m - input matrix for up/down sampling. can be in 0012 % space domain OR in fourier domain, in such 0013 % case, needs to be in matlab format !!! 0014 % (matlab-format = the save as given from fft/fft2) 0015 % out_x_sz,out_y_sz - desired number of pixels in the output image 0016 % is_fourier_flag - 1: the input is given in the fourier domain 0017 % 0: the input is given in the space domain 0018 % (we need to use fft2 to convert to fourier domain) 0019 % is_real_flag - 0: the input is a complex matrix -> don't use 0020 % abs() at the output, perform complex 0021 % up/down sampling 0022 % 1: the input is real BUT has negative values -> 0023 % use real() at the output 0024 % 2: the input is real and positive -> using 0025 % abs() at the output 0026 % 0027 % output: out_m - up/down sampled image 0028 % 0029 % See also MODELUPDATEDSKCF 0030 % 0031 % [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T. 0032 % Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D 0033 % data, Journal of Real-Time Image Processing 0034 % 0035 % University of Bristol 0036 % Massimo Camplani and Sion Hannuna 0037 % 0038 % massimo.camplani@bristol.ac.uk 0039 % hannuna@compsci.bristol.ac.uk 0040 0041 % ============================================== 0042 % get input image size, and calculate the gain 0043 % ============================================== 0044 [in_y_sz,in_x_sz] = size( in_m ); 0045 0046 0047 % build grid vectors for the up/down sampling 0048 % ============================================ 0049 % if the input is even & output is odd-> use floor for all 0050 % if the output is even & input is odd -> use ceil for all 0051 % other cases - don't care 0052 % for downsampling -> the opposite 0053 if (~mod( in_x_sz,2 ) & (out_x_sz>in_x_sz)) | (mod( in_x_sz,2 ) & (out_x_sz<in_x_sz)) 0054 x_output_space = max(floor((out_x_sz-in_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; 0055 x_input_space = max(floor((in_x_sz-out_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; 0056 else 0057 x_output_space = max(ceil((out_x_sz-in_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; 0058 x_input_space = max(ceil((in_x_sz-out_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; 0059 end 0060 if (~mod( in_y_sz,2 ) & (out_y_sz>in_y_sz)) | (mod( in_y_sz,2 ) & (out_y_sz<in_y_sz)) 0061 y_output_space = max(floor((out_y_sz-in_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; 0062 y_input_space = max(floor((in_y_sz-out_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; 0063 else 0064 y_output_space = max(ceil((out_y_sz-in_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; 0065 y_input_space = max(ceil((in_y_sz-out_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; 0066 end 0067 0068 % perform the up/down sampling 0069 in_m = fftshift(in_m); 0070 padded_out_m( y_output_space,x_output_space ) = in_m(y_input_space,x_input_space); 0071 %out_m = (gain_x*gain_y)*ifft2(ifftshift(padded_out_m)); 0072 out_m = ifftshift(padded_out_m); 0073 0074 0075