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:

bullet.gif    For single channel data, the point value is passed as a number. For multi-channel data, the point value is passed as a string of comma-separated numbers. If an RGB string contains fewer values than the number of channels, the last value is duplicated to the remaining channels. For example, "45.2" becomes "45.2,45.2,45.2".

bullet.gif    For single channel data, results are returned as a single number. For RGB data, results are returned as multiple numbers, one for each channel.

bullet.gif    To specify a particular data channel, as when forcing a coefficient value for the B channel, specify the channel as an optional 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 )

AddPt( 3.5, "45.2" ) sets 45.2 for all channels

AddPt( 3.5, "12,56,157" ) sets values for all channels

c = GetCoef( 2 )

r, g, b = GetCoef( 2 ) returns 3 (actually 4) values. one for each channel

ForceCoef( 2, 0.5 )

ForceCoef( 2, 0.5, 3 ) sets coefficient 2 for channel 2.

Related Topics

CLsqFit class, SetNumChannels


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.