diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m deleted file mode 100755 index f88210d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | % [ZOOM] = pixelAxes(DIMS, ZOOM) | ||
2 | % | ||
3 | % Set the axes of the current plot to cover a multiple of DIMS pixels, | ||
4 | % thereby eliminating screen aliasing artifacts when displaying an | ||
5 | % image of size DIMS. | ||
6 | % | ||
7 | % ZOOM (optional, default='same') expresses the desired number of | ||
8 | % samples displayed per screen pixel. It should be a scalar, which | ||
9 | % will be rounded to the nearest integer, or 1 over an integer. It | ||
10 | % may also be the string 'same' or 'auto', in which case the value is chosen so | ||
11 | % as to produce an image closest in size to the currently displayed | ||
12 | % image. It may also be the string 'full', in which case the image is | ||
13 | % made as large as possible while still fitting in the window. | ||
14 | |||
15 | % Eero Simoncelli, 2/97. | ||
16 | |||
17 | function [zoom] = pixelAxes(dims, zoom) | ||
18 | |||
19 | %------------------------------------------------------------ | ||
20 | %% OPTIONAL ARGS: | ||
21 | |||
22 | if (exist('zoom') ~= 1) | ||
23 | zoom = 'same'; | ||
24 | end | ||
25 | |||
26 | %% Reverse dimension order, since Figure Positions reported as (x,y). | ||
27 | dims = dims(2:-1:1); | ||
28 | |||
29 | %% Use MatLab's axis function to force square pixels, etc: | ||
30 | axis('image'); | ||
31 | ax = gca; | ||
32 | |||
33 | oldunits = get(ax,'Units'); | ||
34 | |||
35 | if strcmp(zoom,'full'); | ||
36 | set(ax,'Units','normalized'); | ||
37 | set(ax,'Position',[0 0 1 1]); | ||
38 | zoom = 'same'; | ||
39 | end | ||
40 | |||
41 | set(ax,'Units','pixels'); | ||
42 | pos = get(ax,'Position'); | ||
43 | ctr = pos(1:2)+pos(3:4)/2; | ||
44 | |||
45 | if (strcmp(zoom,'same') | strcmp(zoom,'auto')) | ||
46 | %% HACK: enlarge slightly so that floor doesn't round down | ||
47 | zoom = min( pos(3:4) ./ (dims - 1) ); | ||
48 | elseif isstr(zoom) | ||
49 | error(sprintf('Bad ZOOM argument: %s',zoom)); | ||
50 | end | ||
51 | |||
52 | %% Force zoom value to be an integer, or inverse integer. | ||
53 | if (zoom < 0.75) | ||
54 | zoom = 1/ceil(1/zoom); | ||
55 | %% Round upward, subtracting 0.5 to avoid floating point errors. | ||
56 | newsz = ceil(zoom*(dims-0.5)); | ||
57 | else | ||
58 | zoom = floor(zoom + 0.001); % Avoid floating pt errors | ||
59 | if (zoom < 1.5) % zoom=1 | ||
60 | zoom = 1; | ||
61 | newsz = dims + 0.5; | ||
62 | else | ||
63 | newsz = zoom*(dims-1) + mod(zoom,2); | ||
64 | end | ||
65 | end | ||
66 | |||
67 | set(ax,'Position', [floor(ctr-newsz/2)+0.5, newsz] ) | ||
68 | |||
69 | % Restore units | ||
70 | set(ax,'Units',oldunits); | ||