Last data update: 2014.03.03

R: MultiIm Class
MultiIm-classR Documentation

MultiIm Class

Description

The class contains a list of images and all information required for computing the moments of the images. The images must have the same dimensions and centroid. The object has methods for computing moments and reconstructing the image from moments. Types of moments that can be calculated for this class are: generalized pseudo-zernike, fourier mellin, fourier chebyshev, radial fourier, krawtchouk, hahn, continuous chebyshev, legendre, and gegenbauer.

Creating objects

Objects can be created by calls of the form new("MultiIm", images) where "images" is list of matrices. The dimensions of the images will be checked for consistency when the constructor is called. Moment type, order, and parameters can be set using the class methods.

Slots

imageList:

Object of class "list" Contains a list of image matrices of the same dimension.

dimension:

Object of class "numeric" Contains the dimensions of the images.

polynomials:

Object of class "list" Contains the polynomial values used for computing moments.

storePoly:

Object of class "logi" Default is FALSE. Set to "TRUE" to store polynomial values. For gpzm, fm, fr, and fc moment types, if object@storePoly== TRUE, polynomial values will be stored in the slot "polynomials". Polynomial values for other moment types will always be stored. Set directly by object@storePoly<- TRUE

momentType:

Object of class "character" Contains the moment type.

order:

Object of class "numeric" Contains the maximum order up to which to calculate moments.

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.

moments:

Object of class "list" Contains a list of the moments calculated for each image.

invariant:

Object of class "list" Contains a list of the invariants calculated for each image.

reconstruction:

Object of class "list" Contains the list of reconstructed images.

error:

Object of class "character" Contains the last error message produced from calling a class method.

Methods

momentType<-

signature(obj = "MultiIm"): 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"). Usage: momentType(obj)<- c("krawt", "hahn") or momentType(obj)<-"gpzm"

setOrder<-

signature(obj = "MultiIm"): Set the orders up to which to calculate moments in the x and y directions in the case of real orthogonal moments, or specify order and repetition for complex moment types. Usage: setOrder(obj)<- c(50,50)

setParams<-

signature(obj = "MultiIm"): Set the parameters to be used for calculating moments. If two types of moments are being used, this should be a list of the parameters to be used for each moment type being used. Usage: setParams(obj)<- list(c(0.5), c(1,1))

transform<-

signature(obj = "MultiIm"): Perform a transform of the images which creates an image of the pixels rearranged by polar coordinates. The rows are radius from the centroid and columns are angle. See polarTransform.

Moments<-

signature(obj = "MultiIm"): Calculate the moments of a list of images. Before calling this method the momentType, params, and order must be set. Usage: Moments(obj)<- 0.

Invariant<-

signature(obj = "MultiIm"): Calculate the moment invariants w.r.t. rotation of a list of images. Before calling this method the momentType, params, and order must be set. The method assumes that all images have the same centroid location. For complex moments, the magnitude of the moments are invariant to rotation. Usage: Invariant(obj)<- NULL.
For real orthogonal moments (continuous or discrete), the method normalizes all images prior to computing moments using the same procedure as Invariant<-,OrthIm-method. Usage: Invariant(obj)<- c(5,120)

plotPoly

signature(obj = "MultiIm", order = "list"): Plot the polynomials used to calculate moments of a specified order or array of orders. Usage: plotPoly(obj, list(3:6, 1:4)).

Reconstruct<-

signature(obj = "MultiIm"): Reconstruct the images from moments. Any order lower than or equal to the maximum order calculated can be used for reconstruction. Usage: Reconstruct(obj)<- c(50,50)

Author(s)

Tan Dang

See Also

plotPoly displayImg Image, OrthIm CmplxIm,

Examples


# Load sample data
data(bacteria);

#create MultiIm object, calculate generalized Pseudo-Zernike moments, invariants, and reconstruction for all images
obj <- new("MultiIm", img);
momentType(obj)= c("gpzm");
setOrder(obj)= 20;
setParams(obj)= 1;	# <--- GPZM has 1 parameter
obj@storePoly= TRUE;

## Not run: 
	Moments(obj)= NULL;
	Invariant(obj)= NULL;
	Reconstruct(obj)= NULL;
	#display a subset of polynomials stored in the object
	plotPoly(obj, order=rbind(c(3,2), c(4,2), c(5,3), c(6,3)));
	displayImg(obj@reconstruction[1:5]);

## End(Not run)

## Not run: 
	#create MultiIm object, calculate discrete Chebyshev moments, invariants, and reconstruction for all images
	obj <- new("MultiIm", img);
	momentType(obj)= "cheby"
	setOrder(obj)= 100;
	Moments(obj)= 0;
	Reconstruct(obj)= 75;
	Invariant(obj)= c(7,100); # resolution is 7, scale is 100
	displayImg(obj@reconstruction[1:4]);

## End(Not run)

## Not run: 
	#create MultiIm object, calculate continuous Chebyshev - Legendre moments, invariants, and reconstruction for all images
	obj <- new("MultiIm", img);
	momentType(obj)= c("chebycont", "legend");
	setOrder(obj)= c(100, 110);	
	transform(obj)= 8; 	# perform polar transform on images
	Moments(obj)= 0;
	Reconstruct(obj)= NULL;

	# order of pairs (20,10), (21, 11),...(28,18) will be plotted
	plotPoly(obj, order=cbind(20:28, 10:18));
	displayImg(obj@reconstruction[1:6]);

## End(Not run)

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/MultiIm-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: MultiIm-class
> ### Title: MultiIm Class
> ### Aliases: MultiIm-class initialize,MultiIm-method
> ###   checkSize<-,MultiIm-method momentType<-,MultiIm-method
> ###   setOrder<-,MultiIm-method setParams<-,MultiIm-method
> ###   Moments<-,MultiIm-method Invariant<-,MultiIm-method
> ###   plotPoly,MultiIm,Numbers-method Reconstruct<-,MultiIm-method
> ###   setPoly<-,MultiIm-method transform<-,MultiIm-method
> ### Keywords: classes
> 
> ### ** Examples
> 
> 
> # Load sample data
> data(bacteria);
> 
> #create MultiIm object, calculate generalized Pseudo-Zernike moments, invariants, and reconstruction for all images
> obj <- new("MultiIm", img);
> momentType(obj)= c("gpzm");
> setOrder(obj)= 20;
> setParams(obj)= 1;	# <--- GPZM has 1 parameter
> obj@storePoly= TRUE;
> 
> ## Not run: 
> ##D 	Moments(obj)= NULL;
> ##D 	Invariant(obj)= NULL;
> ##D 	Reconstruct(obj)= NULL;
> ##D 	#display a subset of polynomials stored in the object
> ##D 	plotPoly(obj, order=rbind(c(3,2), c(4,2), c(5,3), c(6,3)));
> ##D 	displayImg(obj@reconstruction[1:5]);
> ## End(Not run)
> 
> ## Not run: 
> ##D 	#create MultiIm object, calculate discrete Chebyshev moments, invariants, and reconstruction for all images
> ##D 	obj <- new("MultiIm", img);
> ##D 	momentType(obj)= "cheby"
> ##D 	setOrder(obj)= 100;
> ##D 	Moments(obj)= 0;
> ##D 	Reconstruct(obj)= 75;
> ##D 	Invariant(obj)= c(7,100); # resolution is 7, scale is 100
> ##D 	displayImg(obj@reconstruction[1:4]);
> ## End(Not run)
> 
> ## Not run: 
> ##D 	#create MultiIm object, calculate continuous Chebyshev - Legendre moments, invariants, and reconstruction for all images
> ##D 	obj <- new("MultiIm", img);
> ##D 	momentType(obj)= c("chebycont", "legend");
> ##D 	setOrder(obj)= c(100, 110);	
> ##D 	transform(obj)= 8; 	# perform polar transform on images
> ##D 	Moments(obj)= 0;
> ##D 	Reconstruct(obj)= NULL;
> ##D 
> ##D 	# order of pairs (20,10), (21, 11),...(28,18) will be plotted
> ##D 	plotPoly(obj, order=cbind(20:28, 10:18));
> ##D 	displayImg(obj@reconstruction[1:6]);
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>