VecIndx Class Function Manual

(   )

| HOME | BACK |

Purpose

To get a value of an element at a particular index in a Vector.  The return result is an Indx object.

The first element index is 0, and the last one is n-1, where n is no of total elements.

Class

VecIndx

Usage

{Indx} ret  =  object({int} argm1)

argm1 = index number

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)


->v(0)

ans = (100 , 200)

->

See also (class function)

init

| HOME | BACK |


AREA

| HOME | BACK |

Purpose

To calculate area of a polygon, constructed by a vector of indices.

Class

VecIndx

Usage

{double} ret  =  object.AREA()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(200,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(200 , 400)

->v.area()

ans = 5000.00000

->

See also (class function)

 

| HOME | BACK |


EXTEND

| HOME | BACK |

Purpose

To increase the maximum size of the vector by a given number.

Class

VecIndx

Usage

{void} object.EXTEND({int} argm1)

argm1 = number of elements wanted to extend

Example:

->v = VecIndx(5)

->v.maxsize()

  ans = 5

->v.extend(500)

->v.maxsize()

  ans = 505

->

See also (class function)

maxsize, truncate

| HOME | BACK |


FIND

| HOME | BACK |

Purpose

To find in a vector object a particular value of element.

The return result is an index of the vector, if found, otherwise it returns -1.

Class

VecIndx

Usage

{int} ret  =  object.FIND({Indx} argm1)

argm1 = value of an element wanted to find

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.find(Indx(100,300))

ans = 1

->

See also (class function)

qfind

| HOME | BACK |


ID

| HOME | BACK |

Purpose

To report the current ID of the vector.

Class

VecIndx

Usage

{int} ret  =  object.ID()

Example:

->v = VecIndx(5)

->v.id()

  ans =   0

->

See also (class function)

maxsize, truncate, extend

| HOME | BACK |


INIT

| HOME | BACK |

Purpose

To initialize a vector object. 

Please be aware that once the vector is initialized, it is still empty.  Only its maximum number of element in the vector is declared.  Use function "pushback" to insert element into a vector.

Class

VecIndx

Usage

{void} object.INIT({int} argm1)

argm1 = number of maximum elements in the vector

Example:

->v = VecIndx()

->v.init(500)

->

See also (class function)

pushback

| HOME | BACK |


LINERAST

| HOME | BACK |

Purpose

To initialize a VecIndx object by rasterization between two given indices.

The result VecIndx object will contains the two initial indices, one at the beginning and one at the end, together with all rasterized indices in the between.

Class

VecIndx

Usage

{void} object.LINERAST({int} argm1, {int} argm2,{int} argm3, {int} argm4)

argm1 = row number of the 1st pixel of the line

argm2 = column number of the 1st pixel of the line

argm3 = row number of the last pixel of the line

argm4 = column number of the last pixel of the line

Example:

->v = VecIndx()

->v.linerast(1,2,5,9)

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 8

(1 , 2)
(2 , 3)
(2 , 4)
(3 , 5)
(3 , 6)
(4 , 7)
(4 , 8)
(5 , 9)

->

See also (class function)

 

| HOME | BACK |


LOAD

| HOME | BACK |

Purpose

To read data from an ASCII file and stored in a VecIndx object.

If file name extension is omitted, the function will add default extensions to the files.  The default extension of an ASCII data file is ".txt".

Unless the path name is given in the file names, the function will search for the files in the current working directory, defined by command "set path".

It is important to make sure that the each line in the file has only 2 fields, the first is read as row number and the second is read as column number.  Both of them are separated by at least one blank, a white space, ASCII 32.

It is possible to have a comment line in the data file, by inserting a slash sign, "/", in front of a line.  Comment lines will not be read by the function.

Class

VecIndx

Usage

{void} object.LOAD({String} argm1)

argm1 = data filename (default extension is ".txt")

Example:

->v = VecIndx()

->v.load("my_data")

->

See also (class function)

save

| HOME | BACK |


LOADSCH

| HOME | BACK |

Purpose

To search for a particular ID block number, then read a block of the data out from an ASCII file and stored in a VecIndx object.

If file name extension is omitted, the function will add default extensions to the files.  The default extension of an ASCII data file is ".txt".

Unless the path name is given in the file names, the function will search for the files in the current working directory, defined by command "set path".

Each line in the data file can either has one field or two fields.  If it has 2 fields, they are separated by at least one blank, a white space, ASCII 32, and the first one is read as row number, while the second one is column number.  A line with one field is interpreted as an ID.

An example of data is:

 

/ an example of data store in a file

101

100   200

300   400

500   600

102

400   600

700   800

900  1000

103

100   100

/...

/... more

 

By using this function "loadsch", it is possible to store separate sets of data in one file, and be able to extract a particular data set within that file.  Each data set must have its own unique ID, for example 101, 102, 103 (see example above).

It is possible to have a comment line in the data file, by inserting a slash sign, "/", in front of a line.  Comment lines will not be read by the function.

Class

VecIndx

Usage

{void} object.LOADSCH({String} argm1)

argm1 = data filename (default extension is ".txt")

Example:

->v = VecIndx()

->v.loadsch("my_data", 102)

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 8

(400 ,  600)
(700 ,  800)
(900 , 1000)


->

See also (class function)

load

| HOME | BACK |


MATRIX

| HOME | BACK |

Purpose

To convert to a Matrix object. 

This function creates a Matrix of size n rows by 2 columns, where n is number of indices in the vector.

Class

VecIndx

Usage

{Matrix} ret  =  object.MATRIX()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->M = v.matrix()

->M

ans =

  no of row    : 3
  no of column : 2

  0:   100.00000    200.00000
  1:   100.00000    300.00000
  2:   100.00000    400.00000

->

See also (class function)

 

| HOME | BACK |


MAX

| HOME | BACK |

Purpose

To compute the maximum value of elements in the vector.

The return result is a Pt2D object, where the x coordinate is the maximum value of row indices, and y coordinate is the maximum vaalue of column indices.

Class

VecIndx

Usage

{Pt2D} ret  =  object.MAX()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.max()

ans = ( 100.000 , 400.000)

->

See also (class function)

min, mean

| HOME | BACK |


MAXSIZE

| HOME | BACK |

Purpose

To report the maximum size of the vector.  This is the maximum number of elements that can be stored in the vector.

Class

VecIndx

Usage

{int} ret  =  object.MAXSIZE()

Example:

->v = VecIndx(5)

->v.maxsize()

  ans =   5

->

See also (class function)

size, truncate, extend

| HOME | BACK |


MEAN

| HOME | BACK |

Purpose

To compute the mean value of indices in the vector.

The return result is a Pt2D object, where the x coordinate is the mean value of row indices, and y coordinate is that of column indices.

Class

VecIndx

Usage

{Pt2D} ret  =  object.MEAN()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.mean()

ans = ( 100.000 , 300.000)

->

See also (class function)

min, max

| HOME | BACK |


MIN

| HOME | BACK |

Purpose

To compute the minimum value of elements in the vector.

The return result is a Pt2D object, where the x coordinate is the minimum value of row indices, and y coordinate is the minimum value of column indices.

Class

VecIndx

Usage

{Pt2D} ret  =  object.MIN()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.min()

ans = ( 100.000 , 200.000)

->

See also (class function)

max, mean

| HOME | BACK |


PUSHBACK

| HOME | BACK |

Purpose

To insert an Index in a vector object.  A new element will be insert at the last available index in the vector.

Suppose the vector has already 4 element in it, when a new element is inserted, the size is updated to 5 and the new element is stored at index number 4.  The first element index is 0, and the last one is n-1, where n is no of total elements.

Class

VecIndx

Usage

{void} object.PUSHBACK({Indx} argm1)

argm1 = an index being inserted

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->

See also (class function)

init

| HOME | BACK |


QFIND

| HOME | BACK |

Purpose

To find in a vector object a particular value of element.  This function expects that the content of the vector is already sorted, or otherwise it will not work correctly.

It performs a binary searching which is much faster than using the function "find".

The return result is an index of the vector, if found, otherwise it returns -1.

Class

VecIndx

Usage

{int} ret  =  object.FIND({Indx} argm1)

argm1 = value of an element wanted to find

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1 = v.sort()

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1.qfind(Indx(100,200))

ans = 0

->

See also (class function)

find

| HOME | BACK |


REMALL

| HOME | BACK |

Purpose

To empty the content of the vector. 

This function can be used to reset the vector very quick.  It simply sets the size of the vector to zero.  It does not do any memory initialization.

Class

VecIndx

Usage

{void} object.REMALL()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.remall()

->print v

->

See also (class function)

remove, remsort

| HOME | BACK |


REMOVE

| HOME | BACK |

Purpose

To remove an element at a particular index out of the vector.

This function replaces the content at the required index with the last element, and simply reduces the size of the vector by 1.

Class

VecIndx

Usage

{void} object.REMOVE({int} argm1)

argm1 = index at which the element being removed

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.remove(0)

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 2

(100 , 400)
(100 , 300)

->

See also (class function)

remall, remsort

| HOME | BACK |


REMSORT

| HOME | BACK |

Purpose

To remove a group of elements, specified by a starting index and ending index, out of the vector.  This function will fill up the gap by shift the rest of the content of the vector forward.

Class

VecIndx

Usage

{void} object.REMSORT({int} argm1,[{int} argm1])

argm1 = start index at which the element being removed

argm2 = ending index at which the element being removed

        (default = the same index as the start index)

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->v.pushback(Indx(100,500))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 4

(100 , 200)
(100 , 300)
(100 , 400)
(100 , 500)

->v.remsort(1,2)

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 2

(100 , 200)
(100 , 500)

->

See also (class function)

remall, remove

| HOME | BACK |


REVERSE

| HOME | BACK |

Purpose

To reverse the content of the vector.

Class

VecIndx

Usage

{Vector} ret  =  object.REVERSE()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->v.pushback(Indx(100,500))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 4

(100 , 200)
(100 , 300)
(100 , 400)
(100 , 500)

->v1 = v.reverse()

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 4

(100 , 500)
(100 , 400)
(100 , 300)
(100 , 200)

->

See also (class function)

sort, qsort

| HOME | BACK |


SAVE

| HOME | BACK |

Purpose

To save as ASCII format.  Each line in the output file represents an element in the vector.

if a file name extension is not given, the function assumes an extension of ".txt".

if a path name is not include in the specified file name, the function will search in the current data path, set by command "set path".

Class

VecIndx

Usage

{void} object.SAVE({String} argm1)

argm1 = output file name

Example:

->v.save("my_data")

->

See also (class function)

load, loadsch

| HOME | BACK |


SHIFT

| HOME | BACK |

Purpose

To shift the values of index by a specific amount of pixels in row and column direction.

Class

VecIndx

Usage

{void} object.SHIFT({double} argm1,{double} argm2)

argm1 = shift in row direction    

argm2 = shift in column direction 

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.shift(-10,10)

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(90 , 210)
(90 , 310)
(90 , 410)

->

See also (class function)

 

| HOME | BACK |


SIZE

| HOME | BACK |

Purpose

To report the current size of the vector.  This is the current number of elements in the vector.

Class

VecIndx

Usage

{int} ret  =  object.SIZE()

Example:

->v = VecIndx(5)

->v.size()

  ans =   0

->

See also (class function)

maxsize, truncate, extend

| HOME | BACK |


SMOOTH

| HOME | BACK |

Purpose

To smooth the line, whose vertices defined by indices in the vector object, using a Douglas-Peucker algorithm. 

The user is required to provide a tolerant distance, which is used to determine whether a vertex will be include in the smooth version of the line.  A vertex is discarded if the distance from it to the line is less than the given tolerance.

Class

VecIndx

Usage

{VecIndx} ret = object.SMOOOTH({double} argm1)

argm1 = tolerant distance (in pixel unit)

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1 = v.smooth(10)

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 2

(100 , 200)
(100 , 400)

->

See also (class function)

 

| HOME | BACK |


SORT

| HOME | BACK |

Purpose

To sort elements of a vector by using Shell sort.

Class

VecIndx

Usage

{VecIndx} ret  =  object.SORT()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1 = v.sort()

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)


->

See also (class function)

qfind

| HOME | BACK |


SWAP_RC

| HOME | BACK |

Purpose

To swap row and column of all indices in the vector.

Class

VecIndx

Usage

{void} object.SWAP_RC()

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v.swap_rc()

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(200 , 100)
(300 , 100)
(400 , 100)

->

See also (class function)

shift

| HOME | BACK |


TRUNCATE

| HOME | BACK |

Purpose

To trim out all the empty space of the current vector.

Suppose a vector has 5 elements in it, and its max size is 500, once it is trimmed, the max size is reduced to 5.  This function does a new memory initialization.

Class

VecIndx

Usage

{void} object.TRUNCATE()

argm1 = number of elements wanted to extend

Example:

->v = VecIndx(5)

->v.maxsize()

  ans = 5

->v.truncate()

->v.maxsize()

  ans = 0

->

See also (class function)

maxsize, extend

| HOME | BACK |


WINDOW

| HOME | BACK |

Purpose

To extract a portion of a vector, specified by a starting index and ending index.

Class

VecIndx

Usage

{VecIndx} ret  =  object.WINDOW({int} argm1,{int} argm2)

argm1 = start index at which the element being extracted

argm2 = ending index at which the element being extracted

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1 = v.window(0,1)

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 2

(100 , 200)
(100 , 300)

->

See also (class function)

window_r, window_rc

| HOME | BACK |


WINDOW_R

| HOME | BACK |

Purpose

To extract indices that fall within a window range, specified by the starting and ending row numbers.

This is a one dimensional search.

Class

VecIndx

Usage

{VecIndx} ret  =  object.WINDOW_R({int} argm1,{int} argm2)

argm1 = start row number of the window

argm2 = end row number of the window

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1 = v.window_r(10,200)

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 2

(100 , 200)
(100 , 300)
(100 , 400)

->

See also (class function)

window, window_rc

| HOME | BACK |


WINDOW_RC

| HOME | BACK |

Purpose

To extract indices that fall within a window range, specified by the starting and ending row and column numbers.

This is a two dimensional search.

Class

VecIndx

Usage

{VecIndx} ret  =  object.WINDOW_RC({int} argm1,{int} argm2,{int} argm3,{int} argm4)

argm1 = start row number of the window

argm2 = end row number of the window

argm1 = start column number of the window

argm2 = end column number of the window

Example:

->v = VecIndx(5)

->v.pushback(Indx(100,200))

->v.pushback(Indx(100,300))

->v.pushback(Indx(100,400))

->print v

Vector of Index (row, column)...

list id : 0

Vector size : 3

(100 , 200)
(100 , 300)
(100 , 400)

->v1 = v.window_rc(10,200,200,400)

->print v1

Vector of Index (row, column)...

list id : 0

Vector size : 2

(100 , 300)

->

See also (class function)

window, window_r

| HOME | BACK |