diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m new file mode 100755 index 0000000..5dac344 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m | |||
@@ -0,0 +1,45 @@ | |||
1 | % [X, Y] = rcosFn(WIDTH, POSITION, VALUES) | ||
2 | % | ||
3 | % Return a lookup table (suitable for use by INTERP1) | ||
4 | % containing a "raised cosine" soft threshold function: | ||
5 | % | ||
6 | % Y = VALUES(1) + (VALUES(2)-VALUES(1)) * | ||
7 | % cos^2( PI/2 * (X - POSITION + WIDTH)/WIDTH ) | ||
8 | % | ||
9 | % WIDTH is the width of the region over which the transition occurs | ||
10 | % (default = 1). POSITION is the location of the center of the | ||
11 | % threshold (default = 0). VALUES (default = [0,1]) specifies the | ||
12 | % values to the left and right of the transition. | ||
13 | |||
14 | % Eero Simoncelli, 7/96. | ||
15 | |||
16 | function [X, Y] = rcosFn(width,position,values) | ||
17 | |||
18 | %------------------------------------------------------------ | ||
19 | % OPTIONAL ARGS: | ||
20 | |||
21 | if (exist('width') ~= 1) | ||
22 | width = 1; | ||
23 | end | ||
24 | |||
25 | if (exist('position') ~= 1) | ||
26 | position = 0; | ||
27 | end | ||
28 | |||
29 | if (exist('values') ~= 1) | ||
30 | values = [0,1]; | ||
31 | end | ||
32 | |||
33 | %------------------------------------------------------------ | ||
34 | |||
35 | sz = 256; %% arbitrary! | ||
36 | |||
37 | X = pi * [-sz-1:1] / (2*sz); | ||
38 | |||
39 | Y = values(1) + (values(2)-values(1)) * cos(X).^2; | ||
40 | |||
41 | % Make sure end values are repeated, for extrapolation... | ||
42 | Y(1) = Y(2); | ||
43 | Y(sz+3) = Y(sz+2); | ||
44 | |||
45 | X = position + (2*width/pi) * (X + pi/4); | ||