Matrix Class Function Manual (P-R) |
Purpose
To compute the value of a specified percentile of a matrix. A 70% percentile is a value at which 70% of data are smaller.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{double} ret = object.PERCENTILE({double} argm1)
For class Matrix_flt
{float} ret = object.PERCENTILE({double} argm1)
For class Matrix_int
{int} ret = object.PERCENTILE({double} argm1)
For class Matrix_sht
{short} ret = object.PERCENTILE({double} argm1)
For class Matrix_uch
{uchar} ret = object.PERCENTILE({double} argm1)
For class Matrix_bln
{bool} ret = object.PERCENTILE({double} argm1)
argm1 = percent at which a percentile value being wanted
Example:
->A = Matrix() |
See also (class function)
mean, median, max, min
Purpose
To find poly-lines in a Matrix. A poly-line is defined by pixels, whose value greater than zero, connected to each other in one direction. This function will detect all connected poly-lines in the matrix, and store the result in a vector of poly-lines, a VecRCpline object.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{VecRCpline} ret = object.POLYLINE()
Example:
->A = Matrix() |
See also (class function)
linefollow
Purpose
To compute a product, a multiplication, of all values in each column.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.PRODCOL()
For class Matrix_flt
{Matrix_flt} ret = object.PRODCOL()
For class Matrix_int
{Matrix_int} ret = object.PRODCOL()
For class Matrix_sht
{Matrix_sht} ret = object.PRODCOL()
For class Matrix_uch
{Matrix_uch} ret = object.PRODCOL()
For class Matrix_bln
{Matrix_bln} ret = object.PRODCOL()
Example:
->a = [ 1 2 3; 4 5 6; 7 8 9] ->b = a.prodcol() ->print b
no of row : 1 |
See also (class function)
prodrow
Purpose
To compute a product, a multiplication, of all values in each row.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.PRODROW()
For class Matrix_flt
{Matrix_flt} ret = object.PRODROW()
For class Matrix_int
{Matrix_int} ret = object.PRODROW()
For class Matrix_sht
{Matrix_sht} ret = object.PRODROW()
For class Matrix_uch
{Matrix_uch} ret = object.PRODROW()
For class Matrix_bln
{Matrix_bln} ret = object.PRODROW()
Example:
->a = [ 1 2 3; 4 5 6; 7 8 9] ->b = a.prodrow() ->print b
no of row : 3 |
See also (class function)
prodcol
Purpose
To create an image pyramid, consisting of a number of Matrix objects, stored in files, at different resolutions.
The 1st level is the same as the original matrix. The 2nd level has number of rows and columns half of those of the 1st level, and so on.
A decrease of resolution is each level is done by skipping data for one row and one column of the previous matrix. There is a Gaussian filter applied to the previous level of matrix prior to skipping. If the standard deviation of the Gaussian filter is not given by the user, the program uses the default value of 0.75.
Each level of a pyramid is stored in a file by a name specified by the user followed by "_n", where n is a level number, and the first level is zero. For example, if an output file name is "my_matrix", the 1st level matrix will have a name of "my_matrix_0". The 2nd level will have a name of "my_matrix_1" and so on.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{void} object.PYRAMID({int} argm1, [{String} argm2, {double} argm3])
argm1 = no of levels of pyramid image
argm2 = output pyramid file name (default = "pyramid")
argm2 = standard deviation of the Gausiian filter (default = 0.75)
Example:
->A.pyramid(5, "my_matrix") -> |
See also (class function)
save
Purpose
To find a particular element within a certain column of a matrix. If found the function returns the row number at which the data is found, otherwise returns -1.
This function performs a binary search, thus it assumes that the matrix is already sorted in the specific column.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{int} ret = object.QFIND({double} argm1,{int} argm2)
For class Matrix_flt
{int} ret = object.QFIND({float} argm1,{int} argm2)
For class Matrix_int
{int} ret = object.QFIND({int} argm1,{int} argm2)
For class Matrix_sht
{int} ret = object.QFIND({short} argm1,{int} argm2)
For class Matrix_uch
{int} ret = object.QFIND({uchar} argm1,{int} argm2)
For class Matrix_bln
{int} ret = object.QFIND({bool} argm1,{int} argm2)
argm1 = data wanted to find in a matrix
argm2 = column number within which the data are searched
Example:
->A = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
find
Purpose
To extract 3 rotation angles from a rotation matrix. The result is a vector of 3 elements, in which the first element is omega, angle about the x-axis, the second is phi , angle about y-axis, and the last is kappa, angle about z-axis.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{vector} ret = object.R2OPK()
Example:
->a = Matrix() ->a.Rxyz(10,20,30)
->print a |
See also (class function)
Rx, Ry, Rz, Rxyz
Purpose
To create a matrix whose element values are random numbers. The random numbers will overwrite all previous values of all elements in the matrix. Thus, the matrix must be initialized to have a certain size, before it can call this function.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{void} object.RAND([{double} argm1])
argm1 = maximum possible value of random number
(default = value set by command "set randmax")
Example:
->A = Matrix(5,5) |
See also (class function)
init, lingen
Purpose
To determine the rank of a matrix
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{int} ret = object.RANK()
Example:
->a = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
rref, inv
Purpose
To convert a row and column number to a number.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{int} ret = object.RC2NO({int} argm1, {int} argm2)
argm1 = row number
argm2 = column number
Example:
->A = Matrix(2,3) ->A.rc2no(0,0) ans = 0 ->A.rc2no(0,2) ans = 2 |
See also (class function)
no2rc
Purpose
To re-assign a new value to elements of a matrix, if the original value is within a certain range, argm1 ≤ x ≤ argm2, specified by argument 1 and argument 2 in the function. Otherwise keeps the original value.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{Matrix} ret = object.REASSIGN({double} argm1, {double} argm2, {double} argm3)
argm1 = start value of the specified range
argm2 = end value of the specified range
argm3 = value to be assigned, if original value is within the range.
Example:
->a = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
reclass
Purpose
To re-assign value of elements of a matrix according to a list of boundary, given by a vector.
The following is an example of a list of boundary values, stored in a vector object, says 5 values: 12 15 20 35 60.
Then the function will classify elements of the matrix, according to their values, into 6 classes, as follows (x is the original value).
class 0 x < 12
class 1 12 ≤ x < 15
class 2 15 ≤ x < 20
class 3 20 ≤ x < 35
class 4 35 ≤ x < 60
class 5 x ≥ 60
Thus each element of the new matrix will be assigned a number from 0 to 5, according to the original values of the calling matrix.
It is very important that values in the specified vector be sorted from small to large values.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.RECLASS({Vector} argm1)
For class Matrix_flt
{Matrix_flt} ret = object.RECLASS({Vector} argm1)
For class Matrix_int
{Matrix_int} ret = object.RECLASS({Vector} argm1)
For class Matrix_sht
{Matrix_sht} ret = object.RECLASS({Vector} argm1)
For class Matrix_uch
{Matrix_uch} ret = object.RECLASS({Vector} argm1)
For class Matrix_bln
{Matrix_bln} ret = object.RECLASS({Vector} argm1)
argm1 = vector contains boundary points
Example:
->a = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
reassign
Purpose
To reshape the size of a matrix.
It is important that the total number of elements of a matrix before and after reshape must be the same.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.RESHAPE({int} argm1, {int} argm2)
For class Matrix_flt
{Matrix_flt} ret = object.RESHAPE({int} argm1, {int} argm2)
For class Matrix_int
{Matrix_int} ret = object.RESHAPE({int} argm1, {int} argm2)
For class Matrix_sht
{Matrix_sht} ret = object.RESHAPE({int} argm1, {int} argm2)
For class Matrix_uch
{Matrix_uch} ret = object.RESHAPE({int} argm1, {int} argm2)
For class Matrix_bln
{Matrix_bln} ret = object.RESHAPE({int} argm1, {int} argm2)
argm1 = new number of rows
argm2 = new number of columns
Example:
->A = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
tsp
Purpose
To reverse values of elements of a matrix.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.REVERSE()
For class Matrix_flt
{Matrix_flt} ret = object.REVERSE()
For class Matrix_int
{Matrix_int} ret = object.REVERSE()
For class Matrix_sht
{Matrix_sht} ret = object.REVERSE()
For class Matrix_uch
{Matrix_uch} ret = object.REVERSE()
For class Matrix_bln
{Matrix_bln} ret = object.REVERSE()
Example:
->a |
See also (class function)
reshape
Purpose
To make an Image_rgb object from a matrix. The colors of the output image are taken from the current color map, a 3-column matrix, by using values of elements of the calling matrix as an index to the color map. The first color in the color map has an index of zero.
Any element having a value less than zero or greater than n-1, where n is the maximum number of color in the current color map, will be assigned a black color, red = 0, green = 0, blue = 0.
See details information of color map in command "set colormap".
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{Image_rgb} ret = object.RGB()
Example:
->A_rgb = A.rgb() -> |
See also (class function)
rgbauto
Purpose
To make an Image_rgb object from a matrix. The calling matrix will be stretched so that its values range from 0 to n-1, where n is the number of colors in the current color map. In contrast to function "rgb", this function will make use of the full scale of the current color map.
See details information of color map in command "set colormap".
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{Image_rgb} ret = object.RGBAUTO()
Example:
->A_rgb = A.rgbauto() -> |
See also (class function)
rgb
Purpose
To rotate a matrix at angle of 180 degree.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.ROT180()
For class Matrix_flt
{Matrix_flt} ret = object.ROT180()
For class Matrix_int
{Matrix_int} ret = object.ROT180()
For class Matrix_sht
{Matrix_sht} ret = object.ROT180()
For class Matrix_uch
{Matrix_uch} ret = object.ROT180()
For class Matrix_bln
{Matrix_bln} ret = object.ROT180()
Example:
->A = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
rot90l, rot90r, fliplr, flipud
Purpose
To rotate a matrix at angle of 90 degree to the left.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.ROT90L()
For class Matrix_flt
{Matrix_flt} ret = object.ROT90L()
For class Matrix_int
{Matrix_int} ret = object.ROT90L()
For class Matrix_sht
{Matrix_sht} ret = object.ROT90L()
For class Matrix_uch
{Matrix_uch} ret = object.ROT90L()
For class Matrix_bln
{Matrix_bln} ret = object.ROT90L()
Example:
->A = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
rot180, rot90r, fliplr, flipud
Purpose
To rotate a matrix at angle of 90 degree to the right.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
For class Matrix
{Matrix} ret = object.ROT90R()
For class Matrix_flt
{Matrix_flt} ret = object.ROT90R()
For class Matrix_int
{Matrix_int} ret = object.ROT90R()
For class Matrix_sht
{Matrix_sht} ret = object.ROT90R()
For class Matrix_uch
{Matrix_uch} ret = object.ROT90R()
For class Matrix_bln
{Matrix_bln} ret = object.ROT90R()
Example:
->A = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
rot180, rot90l, fliplr, flipud
Purpose
To round all element values of a matrix. Values whose decimal parts are larger than or equal to 0.5 will be round up.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{Matrix_int} ret = object.ROUND()
Example:
->a = [ 1.5 2.2
3; 4 5 6; 7.55 8.26 9.0] |
See also (class function)
fix
Purpose
To reduce to a Reduced row-echelon form matrix.
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{Matrix} ret = object.RREF()
Example:
->a = [ 1 2 3; 4
5 6; 7 8 9] |
See also (class function)
rank, inv
Purpose
To create a 3 by 3 rotation matrix of an rotation angle about x-axis.
The unit of rotation angles is the current unit set by command "set angle". The structure of the matrix is as follows (a is an angle).
Rx(a) = | 1 0 0 |
| 0 cos(a) sin(a)|
| 0 -sin(a) cos(a)|
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{void} object.RX({double} argm1)
argm1 = rotation angle about x-axis
Example:
->set angle "deg" |
See also (class function)
ry, rz, rxyz
Purpose
To create a 3 by 3 rotation matrix, such that Rxyz = Rz * Ry * Rx, where Rx, Ry, and Rz are rotation matrixs of an agle about x-axis, y-axis and z-axis respectively.
It is important to know that a different orders of rotation angles give different rotation matrices. Here the function Rxyz is created from first rotate about the x-axis, then the y-axis, and finally about the z-axis.
The unit of rotation angles is the current unit set by command "set angle".
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{void} object.RXYZ({double} argm1, {double} argm2, {double} argm3)
argm1 = rotation angle about x-axis
argm2 = rotation angle about y-axis
argm3 = rotation angle about z-axis
Example:
->set angle "deg" |
See also (class function)
rx, ry, rz
Purpose
To create a 3 by 3 rotation matrix of an rotation angle about y-axis.
The unit of rotation angles is the current unit set by command "set angle". The structure of the matrix is as follows (a is an angle).
Ry(a) = |cos(a) 0 -sin(a)|
| 0 1 0 |
|sin(a) 0 cos(a)|
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{void} object.RY({double} argm1)
argm1 = rotation angle about y-axis
Example:
->set angle "deg" |
See also (class function)
rx, rz, rxyz
Purpose
To create a 3 by 3 rotation matrix of an rotation angle about z-axis.
The unit of rotation angles is the current unit set by command "set angle". The structure of the matrix is as follows (a is an angle).
Rz(a) = | cos(a) sin(a) 0 |
|-sin(a) cos(a) 0 |
| 0 0 1 |
Class
Matrix, Matrix_flt, Matrix_int, Matrix_sht, Matrix_uch, Matrix_bln
Usage
{void} object.RZ({double} argm1)
argm1 = rotation angle about z-axis
Example:
->set angle "deg" |
See also (class function)
rx, ry, rxyz