© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 28 of 52
provided by this command. These are the
Threshold
, the
Hysteresis
, and the
Mode
. These
coefficients are the same as described above in the “TSL1401-DB Monitor Program” section. The
sequence of bytes required by the Set Binary Coefficients command is:
SETBIN
,
Threshold
,
Hysteresis
,
Mode
Where
SETBIN
is a constant having the value
$EC
(mnemonic “enter coefficients”).
Threshold
is the value which determines whether an acquired pixel is a one (light) or a zero (dark).
Hysteresis
is the width of the band above and below
Threshold
, which, in effect, creates two
thresholds: an upper and a lower. A pixel must be at least as high as the upper threshold to cause a
transistion from dark to light; and it must be lower than the lower threshold to cause a transistion from
light to dark. The separation between the two thresholds (the hysteresis band) is twice the value entered
for
Hysteresis
.
The
Mode
byte includes flags that determine the binary acquisition mode, along with the floating
threshold
Filter
value. It’s format is:
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
0: Fixed
1: Floating
0: Level
1: Window
Reserved Reserved Reserved
Filter value for floating threshold:
0 (no filtering) to 7 (maximum)
When
FIXED
thresholding is selected, each pixel is compared to the same, constant, upper and lower
thresholds, defined by
Threshold
and
Hysteresis
. The first pixel is compared to
Threshold
alone to
determine the initial state (
0
or
1
). After that, each pixel is compared with either
Threshold +
Hysteresis
, if the last comparison yielded a
0
, or
Threshold – Hysteresis
, if the last comparison
yeilded a
1
. Both
Threshold
and
Hysteresis
can range from 0 to 255. When their sum is greater than
255, 255 is used as the upper threshold. When their difference is less than 0, 0 is used as the lower
threshold.
When
FLOAT
ing thresholding is selected, the value given for
Threshold
is assumed to be a signed byte
that ranges from
–128
($80) to
127
($7F). It is treated as an offset, which is added to an internal
floating parameter (
Float
) that changes, depending on the values of the pixels that preceded it. For the
first pixel,
Float
is simply assigned the value of that pixel. From there on out,
Float
is modified after
each pixel is processed, according to the formula:
Float = Float + (Pixel - Float) / (1 >> Filter)
Therefore, when
Filter
equals
0
,
Float
takes on the value of the pixel itself. When
Filter
is a larger
number,
Float
becomes a moving average whose time constant increases as
Filter
increases. The new
value of
Float
is used to process the
next
pixel.
Each pixel is then compared with
Float + Thr Hysteresis
, if the previous pixel evaluated to a
0
, or with
Float + Threshold – Hysteresis
, if the previous pixel evaluated to a
1
.
The preceding discussion assumes that
Level
thresholding is in effect. If
Window
thresholding is
selected instead, the upper and lower thresholds are computed as described above, but each pixel is
assigned a
0
if it’s value lies between the two thresholds, and a
1
if it’s value lies above the upper
threshold or below the lower one (i.e. outside the window formed by the hysteresis band).