Working with RGB data
The CLsqFit class is designed to make it easy to fit data having either multiple channels, such as RGB intensities in an image, or regular single channel data that has a single numeric value at a given set of coordinates. Since most uses of multi-channel data involve RGB images, these terms are used interchangeably in this class description.
The CLsqFit class supports 1, 3 and 4 channel data. A fit to multi-channel data performs an independent fit to data in each channel. You can force coefficient values, change fit parameters, alter point properties, and configure data rejection independently for each channel, but the basis function and total number of fit coefficients are the same for each channel.
Fitting multi-channel RGB data uses the same class methods you would use for fitting traditional single-channel (numeric) data. However, the arguments or return values are different for the two cases:
For single channel data, the point value is passed as a number. For multi-channel RGB data, the point value is passed as lua table. If an RGB string contains fewer values than the number of channels, the last values are set to 0. For example, 45.2 becomes {45.2,0,0}.
For single channel data, results are returned as a single number. For RGB data, results are returned as multiple numbers, one for each channel.
To specify a data channel, as when forcing a coefficient value for the B channel, specify the channel as the argument of the method.
Comparison of Methods used for Numeric Data and RGB Data
Numeric Data |
Multi-channel or RGB Data |
|
AddPt( 3.5, 45.2 ) |
|
-- sets 45.2 for the R channel -- sets values for all channels |
c = GetCoef( 2 ) |
|
-- returns 3 or 4 values, one for each channel |
ForceCoef( 2, 0.5 ) |
|
-- sets coefficient 2 for channel 2. |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.