Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slresizeimg
Home > sltoolbox > imgproc > slresizeimg.m

slresizeimg

PURPOSE ^

SLRESIZEIMG Resizes the images by interpolation

SYNOPSIS ^

function rimgs = slresizeimg(imgs, newsiz, interpker)

DESCRIPTION ^

SLRESIZEIMG Resizes the images by interpolation

 $ Syntax $
   - rimgs = slresizeimg(imgs, newsiz, interpker)

 $ Arguments $
   - imgs:         The set of images
   - newsiz:       The new image size to be resized to
                   It can be in two forms:
                   - [new_height, new_width]
                   - ratio to the original size
   - interpker:    The interpolation kernel (default = 'linear')
   - rimgs:        The resized images

 $ Description $
   - rimgs = slresizeimg(imgs, newsiz, interpker) resizes the image
     to new size by interpolation. 

 $ Remarks $
   - The implementation is based on slimginterp.

 $ History $
   - Created by Dahua Lin, on Sep 3, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slimginterp SLIMGINTERP Performs image based interpolation
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
  • sltakeval SLTAKEVAL Extracts the values in an array/cell array to output
This function is called by:

SOURCE CODE ^

0001 function rimgs = slresizeimg(imgs, newsiz, interpker)
0002 %SLRESIZEIMG Resizes the images by interpolation
0003 %
0004 % $ Syntax $
0005 %   - rimgs = slresizeimg(imgs, newsiz, interpker)
0006 %
0007 % $ Arguments $
0008 %   - imgs:         The set of images
0009 %   - newsiz:       The new image size to be resized to
0010 %                   It can be in two forms:
0011 %                   - [new_height, new_width]
0012 %                   - ratio to the original size
0013 %   - interpker:    The interpolation kernel (default = 'linear')
0014 %   - rimgs:        The resized images
0015 %
0016 % $ Description $
0017 %   - rimgs = slresizeimg(imgs, newsiz, interpker) resizes the image
0018 %     to new size by interpolation.
0019 %
0020 % $ Remarks $
0021 %   - The implementation is based on slimginterp.
0022 %
0023 % $ History $
0024 %   - Created by Dahua Lin, on Sep 3, 2006
0025 %
0026 
0027 %% parse and verify input
0028 
0029 if nargin < 2
0030     raise_lackinput('slresizeimg', 2);
0031 end
0032 h0 = size(imgs, 1);
0033 w0 = size(imgs, 2);
0034 
0035 if isnumeric(newsiz)
0036     if length(newsiz) == 1
0037         h = newsiz * h0;
0038         w = newsiz * w0;
0039     elseif length(newsiz) == 2
0040         [h, w] = sltakeval(newsiz);
0041     else
0042         error('sltoolbox:invalidarg', 'The newsiz is invalid');
0043     end
0044 else
0045     error('sltoolbox:invalidarg', 'The newsiz is invalid');
0046 end
0047 
0048 if nargin < 3 || isempty(interpker)
0049     interpker = 'linear';
0050 end
0051 
0052 %% generate coordinate map
0053 
0054 I = linspace(1, h0, h)';
0055 J = linspace(1, w0, w);
0056 I = I(:, ones(1, w));
0057 J = J(ones(h, 1), :);
0058 
0059 %% Do interpolation
0060 
0061 rimgs = slimginterp(imgs, I, J, interpker);
0062 
0063 
0064

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com