% fdscale (Fermi-Dirac Rescaling) by Dan Piehl (2006) % % This is an image rescaler than can accept 2 or 3 dimensional % arrays. The third dimension will always be interpreted as % a color subscript. The function requires a rescaling factor % (eg. pxlscale=4) and a "temperature" correction (eg. tempscale=1). % A mean value correction factor can also be supplied. function b = fdscale(a,pxlscale,tempscale,meancorrect) % Examine parameters and return error messages, if needed numDimsA = ndims(a); % Get the number of input dimensions S1=size(a,1); % Get the number of rows S2=size(a,2); % Get the number of columns S3=size(a,3); % Get the number of color planes if (nargin < 3 ) error('MATLAB:wavelet:NoInputs',['No input arguments specified.']) end if (numDimsA<2 || numDimsA>3) % Only 2 or 3 dimensional arrays are allowed error('MATLAB:wavelet:NoInputs',['Invalid array dimensions.']) end if not (tempscale>0 && pxlscale>0 && pxlscale-floor(pxlscale)==0) error('MATLAB:wavelet:NoInputs',['Invalid scaling parameters.']) end if not ( (S1==1 && S2>1) || (S1>1 && S2==1) || (S1>1 && S2>1) ) error('MATLAB:wavelet:NoInputs',['Invalid array dimensions.']) end % Determine min/max values (this is "linearized" for color images) R=2; % Reset largest search radius CB1=a; % Start with local color basis CB2=a; for iteration=1:3 CB2=1.1*lowpass(CB2); % Identify local change end c=sum((CB2-CB1).^2,3); % Compute basis square distance c=max(cat(3,c,0.0001*ones(S1,S2)),[],3); % Keep distance bounded MinVal=zeros(S1,S2); % Reset minimum and maximum arrays MaxVal=zeros(S1,S2); R=2; % Reset largest search radius for C1=-R:R % Loop through potential circular shift values for C2=-R:R DS=C1^2+C2^2; % Compute pixel distance squared if (DS>0 && DS