bpdq_random_fourier_locations

PURPOSE ^

bpdq_random_fourier_locations : Compute random Fourier locations

SYNOPSIS ^

function [useind,loc]=bpdq_random_fourier_locations(dim,K,varargin)

DESCRIPTION ^

 bpdq_random_fourier_locations : Compute random Fourier locations

 [useind,loc]=bpdq_random_fourier_locations(dim,K,varargin)

 Choses 2*K (or 2*K-1 if center is chosen) random locations 
 respecting fft symmetry,  i.e. if x of dimension dim is real
 then ifft2( ifftshift( fftshift(fft2(x)) .* loc ) )
 will also be real.

 Inputs:
 dim - dimensions of image
 K - # of independent locations desired

 Selectable Control Parameters :
 forcecenter - set to 1 to enforce DC coefficient to be chosen
 seed - pseudorandom seed, set to a real number to seed random number
 generator

 Outputs:
 useind : indices of Fourier coefficient locations
 loc : binary mask of size dim indicating Fourier coefficient locations

 This file is part of BPDQ Toolbox (Basis Pursuit DeQuantizer)
 Copyright (C) 2009, the BPDQ Team (see the file AUTHORS distributed with
 this library) (See the notice at the end of the file.)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % bpdq_random_fourier_locations : Compute random Fourier locations
0002 %
0003 % [useind,loc]=bpdq_random_fourier_locations(dim,K,varargin)
0004 %
0005 % Choses 2*K (or 2*K-1 if center is chosen) random locations
0006 % respecting fft symmetry,  i.e. if x of dimension dim is real
0007 % then ifft2( ifftshift( fftshift(fft2(x)) .* loc ) )
0008 % will also be real.
0009 %
0010 % Inputs:
0011 % dim - dimensions of image
0012 % K - # of independent locations desired
0013 %
0014 % Selectable Control Parameters :
0015 % forcecenter - set to 1 to enforce DC coefficient to be chosen
0016 % seed - pseudorandom seed, set to a real number to seed random number
0017 % generator
0018 %
0019 % Outputs:
0020 % useind : indices of Fourier coefficient locations
0021 % loc : binary mask of size dim indicating Fourier coefficient locations
0022 %
0023 % This file is part of BPDQ Toolbox (Basis Pursuit DeQuantizer)
0024 % Copyright (C) 2009, the BPDQ Team (see the file AUTHORS distributed with
0025 % this library) (See the notice at the end of the file.)
0026 
0027 function [useind,loc]=bpdq_random_fourier_locations(dim,K,varargin)
0028   control_params={'forcecenter',1,...
0029                  'seed',nan};
0030   argselectAssign(control_params);
0031   argselectCheck(control_params,varargin);
0032   argselectAssign(varargin);
0033   
0034   if ~isnan(seed)
0035     rand('seed',seed);
0036   end
0037   
0038   % odim : smallest even dimension less than or equal to dim
0039   odim=floor((dim-1)/2)*2+1;
0040 
0041   if (2*K>prod(odim))
0042     error('too many locations wanted')
0043   end
0044   
0045   % pick random locations from odim
0046   rloc=rand(odim);
0047   rloc=rloc+flipud(fliplr(rloc));
0048   if forcecenter==1
0049     ctr=floor((odim+1)/2);
0050     rloc(ctr)=-1; % smaller, will be picked first
0051   end
0052   
0053   [v,ind]=sort(rloc(:));
0054   thresh=v(2*K);
0055   eind=ind(find(v<=thresh));
0056   oloc=zeros(odim);
0057   oloc(eind)=1;
0058     
0059   % then pad with zeros to recover size dim
0060   % If I do this correctly, the center of size odim matrix
0061   % will be center of size dim matrix
0062   % and zero padded regions will correspond to highest frequencies
0063   % that must be real-valued for fft to be real
0064   
0065   if(odim(1)~=dim(1))
0066     % pad on top
0067     oloc=[zeros(1,size(oloc,2));oloc];
0068   end
0069   if(odim(2)~=dim(2))
0070     oloc=[zeros(size(oloc,1),1),oloc];
0071     % pad on left
0072   end
0073   loc=oloc;
0074   useind=find(loc);
0075 
0076   
0077 % The BPDQ Toolbox is free software: you can redistribute it and/or modify
0078 % it under the terms of the GNU General Public License as published by
0079 % the Free Software Foundation, either version 3 of the License, or
0080 % (at your option) any later version.
0081 %
0082 % The BPDQ Toolbox is distributed in the hope that it will be useful,
0083 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0084 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0085 % GNU General Public License for more details.
0086 %
0087 % You should have received a copy of the GNU General Public License
0088 % along with The BPDQ Toolbox.  If not, see <http://www.gnu.org/licenses/>.

Generated on Mon 06-Jul-2009 14:16:10 by m2html © 2003