R: Class for handling continuous or discrete orthogonal moments...
OrthIm-class
R Documentation
Class for handling continuous or discrete orthogonal moments analysis of an image
Description
This class contains an image and all information about the image required for computing a moments analysis
of the image. The object can be passed to functions to compute moments and reconstruct the image from the moments.
The types of moments that can be calculated using this object are: chebyshev, krawtchouk, hahn, continuous chebyshev,
legendre, and gegenbauer.
Creating Objects
Objects can be created by calls of the form new("OrthIm", img, filename).
First the constructor checks for an input image (img). This can be a multidimensional numeric array or a matrix.
The image is converted to grayscale by summing over all colors and stored in slot "I".
If an input image is not provided, a filename (filename) can be passed to the constructor.
The constructor will then read in the image file and convert it to grayscale.
If a filename is given, it must have the extension ".jpg", ".png", or ".bmp".
Slots
polynomials:
Object of class "list" Contains the polynomials used to calculate moments. First list element contains the polynomials over the x coordinates, the second contains polynomials over the y coordinates. The number of rows is the pixel coordinates, the number of columns is the order of the polynomials.
params:
Object of class "list" Contains the parameters used to calculate the moments. First list element is the parameters for the moments over x coordinates, second is for the y coordinates.
order:
Object of class "numeric" Contains the order used to calculate moments. Two values may be given to calculate different orders in the x and y directions.
I:
Object of class "matrix" Contains the original image, in grayscale.
dimensions:
Object of class "numeric" Contains the dimensions of the image.
centroid:
Object of class "numeric" Contains the x and y coordinates of the centroid (center point) of the image, used for calculating continuous orthogonal moments.
filename:
Object of class "character" Contains the filename of the image.
imType:
Object of class "character" Contains the original image file type.
momentType:
Object of class "character" Contains the types of moments being calculated. Up to two different types may be selected, the first being the type of moments calculated in the x direction, the second being for the y direction. If two different types are chosen, they must both be either discrete or continuous. Choices of discrete moments are: "cheby","krawt","hahn". Choices of continuous moments are: "chebycont","gegen","legendre".
moments:
Object of class "matrix" Contains the moments calculated from the image. Dimensions are order in y direction by order in x direction.
reconstruction:
Object of class "matrix" Contains the image reconstructed from the moments.
error:
Object of class "character" Contains the last error message produced from calling a class method.
Extends
Class "Image", directly.
Methods
Moments<-
signature(obj = "OrthIm"): Calculate the moments of the image. Before calling this method the momentType, params, and order must be set. Usage: Moments(obj) <- 0
Invariant<-
signature(obj = "OrthIm"): Calculate the invariants of the image by normalization before computing moments. polarTransform will be called with resolution=value[1],scale=value[2]. Before calling this method the momentType, params, and order must be set. Usage: Invariant(obj) <- c(6,100)
Reconstruct<-
signature(obj = "OrthIm"): Reconstruct the image from the moments, using moments up to a specified order. If no order value is given, the image will be reconstructed from all available moments. Useage: Reconstruct(obj) <- order
initialize
signature(.Object = "OrthIm"): Constructor. A call to new("OrthIm",img,filename) calls this function and creates an OrthIm object. The object slots I, centroid and dimensions are set. (And filename and imType if a filename was provided)
momentType<-
signature(obj = "OrthIm"): Set the moment type for the moments to be calculated. Takes one character string or an array of 2 character strings, for example c("type1","type2")
plotPoly
signature(obj = "OrthIm", order = "numeric"): Plot the polynomials used to calculate the moments in this object. The order, can be 1 number or several numbers, and the polynomials of those orders will be plotted for all x coordinates.
setOrder<-
signature(obj = "OrthIm"): Set the order up to which to calculate moments in the x and y directions.
setParams<-
signature(obj = "OrthIm"): Set the parameters to be used for calculating moments.
transform<-
signature(obj = "OrthIm"): Perform a transform of the image which creates an image of the pixels rearranged by polar coordinates. The rows are radius from the centroid and columns are angle. The method calls polarTransform with padded=FALSE, scale=0
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/OrthIm-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: OrthIm-class
> ### Title: Class for handling continuous or discrete orthogonal moments
> ### analysis of an image
> ### Aliases: OrthIm-class Moments<-,OrthIm-method Invariant<-,OrthIm-method
> ### Reconstruct<-,OrthIm-method initialize,OrthIm-method
> ### momentType<-,OrthIm-method plotPoly,OrthIm,numeric-method
> ### setOrder<-,OrthIm-method setParams<-,OrthIm-method
> ### transform<-,OrthIm-method
> ### Keywords: classes
>
> ### ** Examples
>
> data(mandril);
> obj <- new("OrthIm",img = img,filename = "");
> momentType(obj) = c("chebycont","legend");
> setOrder(obj) = c(150,150);
> Moments(obj) = NULL;
> Reconstruct(obj) = c(125,125);
> ## Not run:
> ##D displayImg(list(obj@I,obj@moments,obj@reconstruction));
> ##D plotPoly(obj,order=c(100,150));
> ## End(Not run)
>
>
>
>
>
> dev.off()
null device
1
>