jitter_image

PURPOSE ^

Creates multiple, slightly jittered versions of an image.

SYNOPSIS ^

function IJ = jitter_image( I, nphis, maxphi, ntrans, maxtrans, jsiz, reflectflag, scales )

DESCRIPTION ^

 Creates multiple, slightly jittered versions of an image.

 Takes an image I, and generates a number of images that are copies of the original image
 with slight translation and rotation applied.  The original image also appears in the
 final set.  

 The parameter jsiz controls the size of the cropped images.  If jsiz gives a size that's
 substantially smaller than I then all data in the the final set will come from I.
 However, if this is not the case then I may need to be padded first.  The way this is
 done is with padarray with the 'replicate' method.  If jsiz is not specified, it is set
 to be the size of the original image. A warning appears if the image needs to be grown. 
 
 Rotations and translations are specified by giving a range and a maximum value for each.
 For example, if maxphi=10 and nphis=5, then the actual rotations applied are [-10 -5 0 5
 10]. Uses: linspace( -maxphi, maxphi, nphis ); Likewise if maxtrans=3 and ntrans=3 then
 the translations are [-3 0 3]. Each translation is applied in the x direction as well as
 the y direction.  Each combination of rotation, translation in x, and translation in y
 is used (for example phi=5, transx=-3, transy=0), so the total number of images
 generated is R=ntrans*ntrans*nphis).  This function works faster if all of the 
 translation end up being integer valued.

 If the input image is actually a MxNxK stack of images then applies op to each image in
 stack and returns an MxNxKxR where R=(ntrans*ntrans*nphis) set of images. 

 INPUTS
   I           - BW input image (MxN) or images (MxNxK), must have odd dimensions
   nphis       - number of rotations
   maxphis     - max value for rotation
   ntrans      - number of translations 
   maxtrans    - max value for translation
   jsiz        - [optional] Final size of each image in IJ 
   reflectflag - [optional] if true then also adds reflection of each image
   scales      - [optional] nscalesx2 array of vert/horiz scalings

 OUTPUTS
   IJ          - MxNxR or MxNxKxR set of images where R=(ntrans*ntrans*nphis*nscales)
 
 EXAMPLE
   load trees; I = ind2gray(X,map); I = imresize(I,[41 41]); clear X caption map
   % creates 7^2*2 images of slight translations with reflection (but no rotation) 
   IJ = jitter_image( I, 0, 0, 7, 3, [35 35], 1 ); montage2(IJ,1,1)
   % creates 5 images of slight rotations (no translations)
   IJ = jitter_image( I, 5, 25, 0, 0, size(I) ); montage2(IJ,1,1)
   % creates 45 images of both rotation and slight translations
   % alternatively use (maxtrans=3) OR (nphis=5)
   IJ = jitter_image( I, 5, 10, 3, 2 ); montage2(IJ,1,1)
   % additionally create multiple scaled versions
   IJ = jitter_image( I, 1, 0, 1, 0, [], [], [1 1; 2 1; 1 2; 2 2] ); montage2(IJ,1)

 DATESTAMP
   27-Feb-2005  2:00pm

 See also JITTER_VIDEO

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Wed 03-May-2006 23:48:50 by m2html © 2003