Monday, May 13, 2013

SPATIAL TRANSFORMATION part-1

Unknown | 8:15 AM |

SPATIAL TRANSFORMATION

     A spatial transformation (also known as a geometric operation) modifies the spatial relationship between pixels in an image, mapping pixel locations in an input image to new locations in an output image. For simplicity, assume that the image I being considered is formed by projection from scene S (which might be a two- or three-dimensional scene, etc.).
   The spatial domain is the normal image space, in which a change in position in I directly projects to a change in position in S. Distances in I (in pixels) correspond to real distances (e.g. in meters) in S.
Resize image


Syntax
B=imresize(A,scale)
B=imresize(A,[mrowsncols])
[Y,newmap]=imresize(X,map,scale)
[...]=imresize(...,method)
[...] = imresize(..., parameter, value, ...)

Description
B = imresize(A, scale) returns image B that is scale times the size of A. The input image A can be a grayscale, RGB, or binary image. If scale is between 0 and 1.0, B is smaller than A. If scale is greater than 1.0, B is larger than A.
B = imresize(A, [mrows ncols]) returns image B that has the number of rows and columns specified by [mrows ncols]. Either NUMROWS or NUMCOLS may be NaN, in which case imresize computes the number of rows or columns automatically to preserve the image aspect ratio.
[Y newmap] = imresize(X, map, scale) resizes the indexed image X. scale can either be a numeric scale factor or a vector that specifies the size of the output image ([numrows numcols]). By default, imresize returns a new, optimized colormap (newmap) with the resized image. To return a colormap that is the same as the original colormap, use the 'Colormap' parameter (see below).
[...] = imresize(..., method) resizes the indexed image. method can be (1) a text string that specifies a general interpolation method, (2) a text string that specifies an interpolation kernel, or (3) a two-element cell array that specifies an interpolation kernel
Text String Specifying Interpolation Method
Method Name Description
'nearest' Nearest-neighbor interpolation; the output pixel is assigned the value of the pixel that the point falls within. No other pixels are considered.
'bilinear' Bilinear interpolation; the output pixel value is a weighted average of pixels in the nearest 2-by-2 neighborhood
'bicubic' Bicubic interpolation (the default); the output pixel value is a weighted average of pixels in the nearest 4-by-4 neighborhood

(2) Text String Specifying Interpolation Kernel
Kernel Name Description
'box' Box-shaped kernel
'triangle' Triangular kernel (equivalent to 'bilinear')
'cubic' Cubic kernel (equivalent to 'bicubic')
'lanczos2' Lanczos-2 kernel
'lanczos3' Lanczos-3 kernel

(3) Two-element Cell Array Specifying Interpolation Kernel
Form Description
{f,w} f is a function handle for a custom interpolation kernel and w is the custom kernel's width.f(x) must be zero outside the interval -w/2 <= x < w/2. Your function handle f may be called with a scalar or a vector input.

[...] = imresize(..., parameter, value, ...) you can control various aspects of the resizing operation by specifying parameter/value pairs with any of the previous syntaxes. The following table lists these parameters.
Parameter Value
'Antialiasing' A Boolean value that specifies whether to perform antialiasing when shrinking an image. The default value depends on the interpolation method. If the method is nearest-neighbor ('nearest'), the default is false; for all other interpolation methods, the default is true.
'Colormap' A text string that specifies whether imresize returns an optimized colormap or the original colormap (Indexed images only). If set to 'original', the output colormap (newmap) is the same as the input colormap (map). If set to 'optimized', imresize returns a new optimized colormap. The default value is 'optimized'.
'Dither' A Boolean value that specifies whether to perform color dithering (Indexed images only). The default value is true.
'Method' As described above
'OutputSize' A two-element vector, [numrows numcols], that specifies the size of the output image. If you specify NaN for one of the values, imresize computes the value of the dimension to preserve the aspect ratio of the original image.
'Scale' A scalar or two-element vector that specifies the resize scale factors. If you specify a scalar, imresize uses the value as the scale factor for each dimension. If you specify a vector, imresize uses the individual values as the scale factors for the row and column dimensions, respectively.

EXAMPLE 1:
Shrink by factor of two using the defaults of bicubic interpolation and antialiasing.
I = imread('rice.png');
J = imresize(I, 0.5);
subplot(1,2,1), subimage(I), subplot(1,2,2), subimage(J)

clip_image002
EXAMPLE 2:
Shrink by factor of two using nearest-neighbor interpolation. (This is the fastest method, but it has the lowest quality.)
I = imread('rice.png');

J2 = imresize(I, 0.5, 'nearest');
subplot(1,2,1), subimage(I),subplot(1,2,2), subimage(J2)
clip_image004

EXAMPLE 3:
Resize an indexed image
[X, map] = imread('trees.tif');
[Y, newmap] = imresize(X, map, 0.75);

subplot(1,2,1), subimage(X,map),subplot(1,2,2), subimage(Y, newmap)
clip_image006 

EXAMPLE 4:
Resize an RGB image to have 64 rows. The number of columns is computed automatically.
RGB = imread('peppers.png');
RGB2 = imresize(RGB, [64 NaN]);
subplot(1,2,1), subimage(RGB),subplot(1,2,2), subimage(RGB2)
 
clip_image008
(cont…)

1 comment:

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Search

Infolinks In Text Ads

Total Pageviews

Subscribe here

Enter your email address:

Delivered by FeedBurner