source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/toolbox/imdown.m

Last change on this file was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.4 KB
Line 
1function J = imdown(I,method)
2% IMDOWN  Downsample image
3%   J = IMDOWN(I,'sample') downsamples the image I by half by
4%   discarding each other pixel.
5%   
6%   IMDOWN(I,'avg') downsmples by averaging groups of four pixels.
7%
8%   The image is always converted to double format.
9%   
10%   See also IMUP().
11
12% AUTORIGHTS
13% Copyright (C) 2006 Andrea Vedaldi
14%       
15% This file is part of VLUtil.
16%
17% VLUtil is free software; you can redistribute it and/or modify
18% it under the terms of the GNU General Public License as published by
19% the Free Software Foundation; either version 2, or (at your option)
20% any later version.
21%
22% This program is distributed in the hope that it will be useful,
23% but WITHOUT ANY WARRANTY; without even the implied warranty of
24% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25% GNU General Public License for more details.
26%
27% You should have received a copy of the GNU General Public License
28% along with this program; if not, write to the Free Software Foundation,
29% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31I = rgb2double(I) ;
32
33if nargin < 2
34  method = 'sample' ;
35end
36
37switch method
38  case 'sample'
39    J = I(1:2:end,1:2:end,:) ;
40   
41  case 'avg'
42    J = ...
43        I(1:2:end-1,1:2:end-1,:) + ...
44        I(2:2:end,1:2:end-1,:) + ...
45        I(1:2:end-1,2:2:end,:) + ...
46        I(2:2:end,2:2:end,:) ;
47    J = J / 4 ;
48end
Note: See TracBrowser for help on using the repository browser.