qc_perform_substitutions qc_speak navigation bar

Table of Contents

qc_scale_image

Scales an image using anti-aliasing.

Syntax

im_scaled = qc_scale_image(im, scale_factor, supersampling_factor, method)
im_scaled = qc_scale_image(im, scale_factor, supersampling_factor)
im_scaled = qc_scale_image(im, scale_factor)
    

Description

Scales the source image using anti-aliasing to produce a result without the jagged edges typical of simple scaling.

The algorithm oversamples the image according to the given supersampling_factor and interpolation method, while scaling the image. It then applies a low-pass filter and reduces the image to the final size.

The resulting image is always a matrix of doubles, regardless of the input format. The algorithm handles grayscale images (mxn), true colour images (mxnx3) and CMYK images (mxnx4). To display a grayscale image, use CAT to concatenate the 2-D matrix into a 3-D true colour image. For example:

    im_rgb = cat(3, im_grey, im_grey, im_grey);
    image(im_rgb);

This function makes use of the image scaling algorithm provided by Anders Brun.

Parameters

im

The image data as a matrix (mxnx4, mxnx3 or mxnx1).

scale_factor

The scale factor by which to scale the image. Values less than 1.0 shrink the image; values larger than 1.0 expand the image.

supersampling_factor

The factor by which to oversample the image. Values less than one will be treated as one. If this argument is omitted then a value of four is used. A value of two is fastest, but less effective in smoothing the resulting image.

method

The interpolation method to use. Valid interpolation methods are:

Method

Description

'nearest'

nearest neighbor interpolation

'linear'

bilinear interpolation

'spline'

spline interpolation

'cubic'

bicubic interpolation as long asthe data is uniformly spaced, otherwise the same as 'spline' The default method is 'cubic'. The fastest, but least effective method is 'nearest'.

Outputs

im_scaled

The scaled image as a double matrix.

Examples

im = imread('mypicture.png');        % read image into variable 'im'
im_scaled = qc_scale_image(im, 0.5); % shrink image to half its original size
image(im_scaled);                    % plot image
    

See Also

 

navigation bar