Skip to contents

cartToPolar converts the x and y coordinates of a vector field (for instance, as generated by spatialGradient) and computes their polar representation (magnitude and angle).

Usage

cartToPolar(x, y, magnitude = "new", angle = "new", degree = FALSE)

Arguments

x

A 32- or 64-bit (32F or 64F) Image object corresponding to the x coordinates of the vector field.

y

A 32- or 64-bit (32F or 64F) Image object corresponding to the y coordinates of the vector field.

magnitude

The location where the magnitude should be stored. It can take 2 values:

  • "new":a new Image object is created and the results are stored inside (the default).

  • An Image object:the results are stored in another existing Image object. Note that an error will be thrown if magnitude does not have the same dimensions, number of channels, and bit depth as x and y.

angle

The location where the angle should be stored. It can take 2 values:

  • "new":a new Image object is created and the results are stored inside (the default).

  • An Image object:the results are stored in another existing Image object. Note that an error will be thrown if angle does not have the same dimensions, number of channels, and bit depth as x and y.

degree

A logical indicating whether the angles are measured in radians (the default) or degrees.

Value

If magnitude="new" and angle="new", the function returns a list containing two Image objects. If magnitude and

angle are Image objects, the function returns nothing and modifies these Image objects in place.

Author

Simon Garnier, garnier@njit.edu

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
field <- spatialGradient(balloon)
lapply(field, changeBitDepth, bitdepth = "32F", target = "self")
#> $dx
#> NULL
#> 
#> $dy
#> NULL
#> 
field_converted <- cartToPolar(field$dx, field$dy)