1% IM = mkDisc(SIZE, RADIUS, ORIGIN, TWIDTH, VALS) 2% 3% Make a "disk" image. SIZE specifies the matrix size, as for 4% zeros(). RADIUS (default = min(size)/4) specifies the radius of 5% the disk. ORIGIN (default = (size+1)/2) specifies the 6% location of the disk center. TWIDTH (in pixels, default = 2) 7% specifies the width over which a soft threshold transition is made. 8% VALS (default = [0,1]) should be a 2-vector containing the 9% intensity value inside and outside the disk. 10 11% Eero Simoncelli, 6/96. 12 13function [res] = mkDisc(sz, rad, origin, twidth, vals) 14 15if (nargin < 1) 16 error('Must pass at least a size argument'); 17end 18 19sz = sz(:); 20if (size(sz,1) == 1) 21 sz = [sz sz]; 22end 23 24%------------------------------------------------------------ 25% OPTIONAL ARGS: 26 27if (exist('rad') ~= 1) 28 rad = min(sz(1),sz(2))/4; 29end 30 31if (exist('origin') ~= 1) 32 origin = (sz+1)./2; 33end 34 35if (exist('twidth') ~= 1) 36 twidth = 2; 37end 38 39if (exist('vals') ~= 1) 40 vals = [1,0]; 41end 42 43%------------------------------------------------------------ 44 45res = mkR(sz,1,origin); 46 47if (abs(twidth) < realmin) 48 res = vals(2) + (vals(1) - vals(2)) * (res <= rad); 49else 50 [Xtbl,Ytbl] = rcosFn(twidth, rad, [vals(1), vals(2)]); 51 res = pointOp(res, Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0); 52% 53% OLD interp1 VERSION: 54% res = res(:); 55% Xtbl(1) = min(res); 56% Xtbl(size(Xtbl,2)) = max(res); 57% res = reshape(interp1(Xtbl,Ytbl,res), sz(1), sz(2)); 58% 59end 60 61 62