 ImageTools - Maple Programming Help

Home : Support : Online Help : Graphics : Image Processing : ImageTools Package : ImageTools/Rotate

ImageTools

 Rotate
 rotate an image in increments of 90 degrees

 Calling Sequence Rotate( img, angle, opts )

Parameters

 img - Image; input image angle - amount of rotation, in radians, counter-clockwise around the image center. opts - (optional) equation(s) of the form option = value; specify options for the Rotate command

Options

 • output = Image
 Specifies a data structure into which the output is written. This can be used to avoid allocating memory. The size and number of layers must match that of the input. The dimensions of the output image are adjusted so that the row and column indices match the input. The default is NULL.
 If no output option is specified, Rotate will allocate an output image based on what the extent option would return.
 The degrees option is used to indicate that the rotation is given in degrees instead of radians.
 If the extent option is given, Rotate returns the height and width of a (possibly larger) image in which the input image must be centered to ensure that no part of the input image is lost during the rotation. This can be used to allocate a suitable image for the output option.
 The background option specifies a color to be used to fill in the extra space around the rotated input image. If not specified, Rotate will use a default of 50% gray. Furthermore, for RGBA images, the alpha channel will be set to 0 (i.e., completely transparent). The background can be specified as a numeric value, a list of 3 or 4 numeric values, or the names black or white.

Description

 • The Rotate command returns an image that has been rotated by the specified angle.
 • The img parameter is of type Image.
 • The angle parameter specifies the angle of rotation in a counter-clockwise direction. It may be a numeric value, or one of the names left or right. An angle of Pi/2 radians is equivalent to left.
 • If an image is rotated such that it would fit better in a rectangle rotated 90 degrees relative to the input, the output image will have its dimensions exchanged. For example, rotating a 400 by 300 image by Pi/3 radians (60 degrees) will produce a 300 x 400 image. Thus, the dimensions of the output image should always be checked before attempting to index into it.

Examples

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$
 > $\mathrm{img}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦0.5+\mathrm{evalf}\left(\mathrm{exp}\left(-\frac{c}{50}\right)\cdot 0.5\cdot \mathrm{sin}\left(\frac{r}{20}\right)\right)\right)$
 ${{\mathrm{_rtable}}}_{{18446884025564705006}}$ (5.1)
 > $\mathrm{img1}≔\mathrm{Rotate}\left(\mathrm{img},90,'\mathrm{degrees}'\right)$
 ${{\mathrm{_rtable}}}_{{18446884025483061958}}$ (5.2)
 > $\mathrm{img2}≔\mathrm{Rotate}\left(\mathrm{img},180,'\mathrm{degrees}'\right)$
 ${{\mathrm{_rtable}}}_{{18446884025483050030}}$ (5.3)
 > $\mathrm{img3}≔\mathrm{Rotate}\left(\mathrm{img},270,'\mathrm{degrees}'\right)$
 ${{\mathrm{_rtable}}}_{{18446884025483038102}}$ (5.4)
 > $\mathrm{img4}≔\mathrm{Rotate}\left(\mathrm{img},\frac{\mathrm{\pi }}{4.0}\right)$
 ${{\mathrm{_rtable}}}_{{18446884025483026174}}$ (5.5)
 > $\mathrm{img5}≔\mathrm{Rotate}\left(\mathrm{img},\frac{\mathrm{\pi }}{3.0},'\mathrm{background}'='\mathrm{white}'\right)$
 ${{\mathrm{_rtable}}}_{{18446884025463431406}}$ (5.6)
 > $\mathrm{Embed}\left(\left[\left[\mathrm{img},\mathrm{img1}\right],\left[\mathrm{img2},\mathrm{img3}\right],\left[\mathrm{img4},\mathrm{img5}\right]\right]\right)$      > $\mathrm{Rotate}\left(\mathrm{img},\frac{\mathrm{\pi }}{4.0},'\mathrm{extent}'\right)$
 ${270}{,}{354}$ (5.7)
 >