CLsqFit:FindPt
The FindPt method returns the index of a point based on matching its values and, optionally, its channel. If a channel is specified, then the index returned is the index of the point for that channel.
n = CLsqFit:FindPt( x, V ) n = CLsqFit:FindPt( x, V, nChannel ) n = CLsqFit:FindPt( tableX, V ) n = CLsqFit:FindPt( tableX, V, nChannel ) n1, n2, n3, n4 = CLsqFit:FindPt( x, V ) n1, n2, n3, n4 = CLsqFit:FindPt( tableX, V ) |
x is the coordinate for dimension 1 of the sample point.
tableX is a 1-dimensional array containing n values for the n independent variables of the sample point. Use this form when the basis function takes more than 1 independent variable (i.e., the basis function uses more than 1 dimension).
V is the observed value at coordinate x or coordinate vector x. When fitting single channel (numeric) data, this is a number. When fitting multi-channel (e.g., RGB) data, this is a string with the channel values separated by commas.
nChannel is an optional parameter which specifies the channel to search. If omitted, all channels are searched.
n, n1, n2, n3, and n4 are the indices of the point in the sample data or in the channels of multi-channel (e.g., RGB) data. The number of values returned equals the number of channels.
The FindPt method returns the index of the target point in the sample data of the specified channel. If the channel is omitted, then the only channel, or first channel of multi-channel data, is searched. The arguments of this method are similar to that of the AddPt method except that an optional channel index may be specified.
The following example illustrates how to change the weight of an existing point. In this case, the target point's index is found by matching its values:
|
-- create a CLsqFit object |
|
-- set 2 coefficients |
|
-- add a point for x = 3.5 and y = 5.15 |
-- add more points to the fit |
|
|
-- Fit the line |
|
-- do something with the fit results |
|
-- find the point (if we don't know it has index 1) |
|
-- if the point has weight > 5 |
|
-- reduce the weight of the point to 2.5 |
|
|
|
-- get a new fit result using different weights |
The next example illustrates how to change the weight of a point having more than 1 independent variable. This requires passing the independent variables using a table:
|
-- create a CLsqFit object |
|
-- set 2 coefficients each for 3 independent variables |
|
-- add a point with tableX = {3,4,5} and V = 7.25 |
-- add more points to the fit |
|
|
-- Fit the function |
-- do something with the fit results |
|
|
-- find the point (if we don't know it has index 1) |
|
-- if the point has weight > 5 |
|
-- reduce the weight of the point to 2.5 |
|
|
|
-- get a new fit result using different weights |
CLsqFit class, AddPt, Working with RGB data
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.