Last data update: 2014.03.03

R: Represent an image by plotting radius against angle
polarTransformR Documentation

Represent an image by plotting radius against angle

Description

Perform a polar transform of an image by calculating the polar coordinates of the pixels in an image and rearranging the pixels into a plot of angle (theta) against radius. The polar coordinates are calculated with respect to the centroid, determined by calcCentroid or the center of the image space. All transformed images will be shifted to principal axis determined by:

θ=frac{1}{2}arctan(frac{2μ_{00}}{μ_{10}-μ_{01}})

where

μ_{pq}= ∑_{1}^{N} ∑_{1}^{M}(x-x0)^p(y-x0)^q f(x,y)

with (x0, y0) are centroid computed by calcCentroid

Usage

polarTransform(I, resolution, scale, center)

Arguments

I

Image represented as a matrix or numeric array

resolution

An integer which determines the number of angle values between 0 and 2pi to be represented in the transform.

scale

Integer. Default is 0, no scaling in the transformation. If set to a positive integer, the maximum radius used in the transformation will be set to scale, and the transformed image will have dimensions scale, (scale*resolution)

center

The x and y coordinates of the centroid to be used in the transform. If this argument is not provided, the center of the image space will be the centroid.

Details

This transformation is performed by finding the Euclidean coordinates of points which are contained within the smallest circle with origin at the centroid or center of image which can be contained within the image boundaries. The pixels whose coordinates most closely match these Euclidean coordinates are plotted at the corresponding polar coordinates. At each radius, the perimeter is divided into radius * resolution equally spaced point. Then, the Euclidean coordinates of the points will be used in the transformation. This results in a upper-triangular matrix. This transform was created to approximate rotational invariance for orthogonal moments. revPolar is the inverse transform of polarTransform.

Value

PI

The transformed image.

pAxis

The principal axis of the image.

resolution

The resolution used for the transformation.

scale

The scale used for the transformation.

center

The centroid used for the transformation.

Author(s)

Allison Irvine, Tan Dang

See Also

revPolar, polarXY, calcCentroid

Examples

data(circles);
I=rowSums(img,dims=2)
R=polarTransform(I, 6, 100);
displayImg(list(I,R[[1]]));

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(IM)
Loading required package: png
Loading required package: jpeg
Loading required package: bmp
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IM/polarTransform.Rd_%03d_medium.png", width=480, height=480)
> ### Name: polarTransform
> ### Title: Represent an image by plotting radius against angle
> ### Aliases: polarTransform polarTransform-methods
> ###   polarTransform,matrix,numeric,numeric,numeric-method
> ###   polarTransform,matrix,numeric-method
> ### Keywords: utilities
> 
> ### ** Examples
> 
> data(circles);
> I=rowSums(img,dims=2)
> R=polarTransform(I, 6, 100);
> displayImg(list(I,R[[1]]));
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>