Grid
Top  Previous  Next

This object encapsulates ImageWarp's global data grid. The global grid allows you to collect the results of the measurement functions in the memory rather than in a data file, thus drastically minimizing the time needed to access the data. The global data grid can be visualized as a table in which each row represents an object measured and each column represents a measurement parameter.

ImageWarp's measurement parameters are divided into two types: the scalar and vector ones. Scalar parameters, such as Area, Circularity, Dmax, render one numerical result for each object measured. An individual cell of the grid corresponding to a scalar parameter contains a value of this parameter measured for a given object. Unlike the scalar parameters, vector parameters render an array of values for each object measured. The examples of such parameters are Histogram, Moments, Radii. An individual grid's cell corresponding to a vector parameter contains an array of values. The size of the same parameter-array can be different for different objects.

The Grid object provides methods for accessing data collected in the grid and obtaining information about the data format.

Methods
 
show ([ integer Show =1 ] )  
 
Displays or hides the global data grid.  
 
Show – an optional boolean integer specifying weather the grid should be displayed or hidden. If TRUE or omitted, the grid will be refreshed and displayed.  
 
load ( string File )  
 
.Loads ImageWarp data file into the grid  
 
File – the name of the file to be loaded. The file must be of the dbs format. .  
 
save ( string File )  
 
Saves the data from the grid into an ImageWarp's data file.  
 
File – the name of the ImageWarp dbs file.  
 
saveAsText ( string File )  
 
Saves the data from the grid into a text file.  
 
File – the name of the text file.  
 
 
setFormat ( string Param1, string Unit1, string Param2, string Unit 2 [, … ] )  
 
Establishes the grid's format and initializes the grid.  
 
Param1, Param2,… – strings specifying the names of the parameters for each grid's column from left to right. The number of names entered will define the number of columns in the grid.  
 
Unit1, Unit2,… – strings specifying the names of measurement units for each parameter in the grid.  
 
setRowCount ( int Rows )  
 
Changes the number of rows in the grid.  
 
Rows – a positive integer specifying the new number of rows in the grid. If this parameter exceeds the current number of rows, the new empty rows will be added to the end of the grid. If this parameter is less than the current number of rows, extra rows will be removed from the bottom of the grid.  
 
val = getCount ([ integer Class =0 ] )  
 
Returns the number of objects of a specified class in the grid.  
 
Class – an optional positive integer specifying the class of objects. If this parameter is zero or omitted, the function will return the number of all objects (rows) in the grid.  
 
val = getParamSize ( integer Object, string Param )  
 
Returns the number of elements in a vector parameter measured for the specified object. For a scalar parameter this function will return 1.  
 
Object – a positive integer specifying the number of the object in the grid. This is equal to the number of the corresponding row.  
 
Param – a string specifying the name of the measurement parameter whose size is to be retrieved. See selectParam for the list of parameters supported by ImageWarp.  
 
val = getParamValue ( integer Object, string Param, floating Value [, integer Index =0 ] )  
or
val = getParamValue ( integer Object, integer Column, floating Value [, integer Index =0 ] )  

Returns the value of a specified measurement parameter for a given object.  
 
Object – a positive integer specifying the number of the object in the grid. This is equal to the number of the corresponding row.  
 
Param – a string specifying the name of the measurement parameter whose value is to be set. See selectParam for the list of parameters supported by ImageWarp.  
 
Column – a positive integer specifying the ordinal number of the measurement parameter (grid's column) whose value is to be set.  
 
 
Index – an optional integer specifying the index of the element in a vector parameter. This argument is ignored for scalar parameters.  
 
 
val = getParamSum ( string Param [, integer Class =0 ] )  
 
Returns the sum of values of the specified parameter.  
 
val = getParamMax ( string Param [, integer Class =0 ] )  
 
Returns the maximum value of the specified parameter.  
 
val = getParamMin ( string Param [, integer Class =0 ] )  
 
Returns the minimum value of the specified parameter.  
 
val = getParamMed ( string Param [, integer Class =0 ] )  
 
Returns the median (middle value) of the specified parameter.  
 
val = getParamAvg ( string Param [, integer Class =0 ] )  
 
Returns the average value (arithmetic mean) of the specified parameter.  
 
val = getParamGMean ( string Param [, integer Class =0 ] )  
 
Returns the geometric mean of the specified parameter.  
 
val = getParamHMean ( string Param [, integer Class =0 ] )  
 
Returns the harmonic mean of the specified parameter.  
 
val = getParamVar ( string Param [, integer Class =0 ] )  
 
Returns the population variance (N weighting) of the specified parameter.  
 
val = getParamVars ( string Param [, integer Class =0 ] )  
 
Returns the sample variance (N-1 weighting) of the specified parameter.  
 
val = getParamStd ( string Param [, integer Class =0 ] )  
 
Returns the population standard deviation (N weighting) of the specified parameter.  
 
val = getParamStds ( string Param [, integer Class =0 ] )  
 
Returns the sample standard deviation (N-1 weighting) of the specified parameter.  
 
val = getParamMsq ( string Param [, integer Class =0 ] )  
 
Returns the mean of squares of the specified parameter.  
 
val = getParamAvgStd ( string Param [, integer Class =0 ] )  
 
Returns the average of the absolute deviations of the specified parameter.  
 
Param – a string specifying the name of the measurement parameter for which statistics is collected.  
 
Class – an optional positive integer specifying the class of objects for which statistics is collected. If this parameter is zero or omitted, the function will return the corresponding statistical value of the specified  
parameter for all objects (rows) in the grid.  
 
setParamValue ( integer Object, string Param, floating Value [, integer Index =0 ] )  
or
setParamValue ( integer Object, integer Column, floating Value [, integer Index =0 ] )  

Sets the value of a specified measurement parameter for a given object.  
 
Object – a positive integer specifying the number of the object in the grid. This is equal to the number of the corresponding row.  
 
Param – a string specifying the name of the measurement parameter whose value is to be set. See selectParam for the list of parameters supported by ImageWarp.  
 
Column – a positive integer specifying the ordinal number of the measurement parameter (grid's column) whose value is to be set.  
 
Value – a floating variable specifying the value to be assigned to a selected parameter. This is equal to the number of the corresponding row.  
 
Index – an optional integer specifying the index of the element to be set in a vector parameter. This argument is ignored for scalar parameters.  
 
Error flags
 
ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
Examples
 
This set of statements binarizes a sample image, measures a series of parameters and uses the Grid object to retrieve and print the results:  
 
setCurDir ("samples")  
loadIm (1,"sample8.iwd")  
threshRGB(1, 2 , M_PRESET , TRUE, 1, 87,213, 46,151, 143,220)  
scrap(2,2,0,100,M_REJECT)  
resetParam()  
selectParam ("Area","Circularity","DCircle","BlueAvrg","Histogram","Moments")  
measObjects (2,1)  
Print "Area of object 10: ",Grid.GetParamValue(10,"Area")  
Print "Circularity of obj 16: ",Grid.GetParamValue(16,"Circularity")  
hst=grid.GetParamValue(13,"Histogram",128)  
Print "Histogram bin #128 of obj 8: ",hst  
M02=Grid.GetParamValue(20,"Moments",0)  
M11=Grid.GetParamValue(20, "Moments",1)  
M20=Grid.GetParamValue(20, "Moments",2)  
M03=Grid.GetParamValue(20, "Moments",3)  
M12=Grid.GetParamValue(20, "Moments",4)  
M21=Grid.GetParamValue(20, "Moments",5)  
M30=Grid.GetParamValue(20, "Moments",6)  
Print strFormat("Central moments of object 20: %.2f %.2f %.2f %.2f %.2f %.2f %.2f", M02, M11, M20, M03, M12, M21, M30)  
 
The following set of statements captures a sequence from the video device, measures the average intensity of each frame in the sequence and builds a grid containing the average intensity versus time elapsed:

inp = 1  
inv =101  
grabSeq(inp, 10, 50)  
database = "c:\\temp.dbs"  
delfile(database)  
count = GetFrameCount(inp)  
Grid.SetFormat("Intensity","","Time","ms")  
Grid.SetRowCount(count)  
setHistAttr(256,0,255,2,0,1)  
time=0  
for i=1 to count  
 seqExtract(inp, inv,i-1)  
 measHistogram(inv,CH_LUM,HS_STAT,database)    
 lum   = GetparamValue("Histogram", 0)    
 time  = time+GetFrameDelay(inp,i-1)  
 Grid.SetParamValue(i,2,time)  
 Grid.SetParamValue(i,1,lum)  
next  
delfile(database)  
 
Remark
 
For the list of supported measurement parameters refer to ImageWarp User's Guide.