.BG
.FN cwtpolar
.TL
Conversion to Polar Coordinates
.DN
Converts one of the possible outputs of the function {\tt cwt} 
to modulus and phase.
.CS
cwtpolar(cwt, threshold=0)
.RA
.AG cwt
3D array containing the values of a continuous wavelet
transform in the format (signal\_size x noctave x
nvoice) as in the output of the function "cwt" with the
logical flag "twodimension" set to FALSE.
.OA
.AG threshold
 value of a level for the absolute
value of the modulus below which 
the value of the argument of the output is set to -pi.
.RT
Modulus and Argument of the values of the continuous wavelet transform

output1:3D array giving the values (in the same
format as the input) of the modulus of the input.

output2:3D array giving the values of the argument of the input 
.SE
.DT
The output contains the (complex) values of the wavelet transform of the
input signal. The format of the output can be 

2D array (signal\_size x nb\_scales)

3D array (signal\_size x noctave x nvoice) 
.SH REFERENCES
.SA
"cwt", "DOG", "cwtimage"
.EX
# The function is currently defined as
function(cwt, threshold = 0)
{
#########################################################################
#       cwtpolar:   
#       --------
# 	continuous wavelet transform conversion:
#        converts one of the possible outputs of cwt to modulus and phase
#
#       input:
#       ------
# 	 cwt: 3D array containing a continuous wavelet transform (output
#		of cwt, with twoD=FALSE)
#	 threshold: the phase is forced to -pi if the modulus is 
#		less than threshold.
#
#       output:
#       -------
#        output1: modulus
#        output2: phase      
#
#########################################################################
	tmp1 <- cwt
	sigsize <- dim(tmp1)[1]	# sig size
	noctave <- dim(tmp1)[2]
	nvoice <- dim(tmp1)[3]
	output1 <- array(0, c(sigsize, noctave, nvoice))
	output2 <- array(0, c(sigsize, noctave, nvoice))
	for(i in 1:noctave)
		for(j in 1:nvoice) {
			output1[, i, j] <- sqrt(Re(tmp1[, i, j]) * Re(tmp1[, i, 
				j]) + Im(tmp1[, i, j]) * Im(tmp1[, i, j]))
			output2[, i, j] <- atan(Im(tmp1[, i, j]), Re(tmp1[, i, 
				j]))
		}
	ma <- max(output1)
	rel <- threshold * ma
	dim(output1) <- c(sigsize * noctave * nvoice, 1)
	dim(output2) <- c(sigsize * noctave * nvoice, 1)
	output2[abs(output1) < rel] <- -3.14159
	dim(output1) <- c(sigsize, noctave, nvoice)
	dim(output2) <- c(sigsize, noctave, nvoice)
	list(modulus = output1, argument = output2)
}
.KW ~keyword
.WR
