To obtain TAM image, we first calculate the mean values in three color channels \left({F}_{\mathsf{\text{R}}},{F}_{\mathsf{\text{G}}},{F}_{\mathsf{\text{B}}}\right) of original image F by
\left[\overline{{}_{F}^{\mathsf{\text{R}}}}\phantom{\rule{0.5em}{0ex}}\overline{{}_{F}^{\mathsf{\text{G}}}}\phantom{\rule{0.5em}{0ex}}\overline{{}_{F}^{\mathsf{\text{B}}}}\right]=\frac{1}{M}\left(\sum _{k\in {}^{F}}^{k=1,...,M}\left[{F}_{\mathsf{\text{R}}}^{k}\phantom{\rule{0.5em}{0ex}}{F}_{\mathsf{\text{G}}}^{k}\phantom{\rule{0.5em}{0ex}}{F}_{\mathsf{\text{B}}}^{k}\right]\right)
(3)
where {F}_{\mathsf{\text{R}}}^{k} denotes the k th pixel of image F in R channel, and M is the number of pixels.
In Figure 3, tricolor attenuation order for the first original image is m\u2022\overline{{F}_{R}}/\overline{{F}_{B}}\phantom{\rule{0.5em}{0ex}}>\text{1}>\phantom{\rule{0.5em}{0ex}}n\u2022\overline{{F}_{G}}/\overline{{F}_{B}} and for the second one is m\u2022\overline{{F}_{R}}/\overline{{F}_{B}}\phantom{\rule{0.5em}{0ex}}>n\u2022\overline{{F}_{G}}/\overline{{F}_{B}}>\text{1}, therefore the corresponding TAM images are formed by RG and RB, respectively. Shadows are dark in TAM images, which provide strong information for shadow detection. However, sometimes the TAMbased channel subtraction procedure may cause not only shadows, but also some other objects become dark. Just take the second TAM image of Figure 3 as an example, the TAM image is formed by subtracting the blue channel from the red channel, not only the shadows but also some blue objects (e.g., the flowerpot) become dark. The flowerpot may be falsely classified as a shadow after binarization. TAM assumes a shadow and its nonshadow background share an identical reflectance property, that's why our previous study [1] requires a priori segmentation to ensure shadows are detected on uniform reflectance regions. Additionally, the subtraction will smooth pixel values because of the high correlation among R, G, and B components [22]. The smoothing may cause details missing in detection results. The first image of Figure 4 demonstrates that there are false detections and details missing if we only employ TAM (without segmentation) to detect shadows.
As mentioned above, though TAM can provide information for shadow detection, it may suffer from false detection and details missing problems. These problems caused by luminance information are lost during the channelsubtraction procedure. Fortunately, the lost information in the TAM image can be compensated by intensity (grayscale) image. The problem then becomes how to combine intensity image with TAM image. In the following, we will give a method to address it meanwhile to derive a threshold for shadow segmentation.
Combined image Z is obtained by combing TAM image X with intensity image Y as follows:
where α is the weight coefficient. We define the objective function as:
\zeta \left(T\right)=G\left(T\right)\cdot \left(\overline{Z\cap {S}^{C}\left(T\right)}\overline{Z\cap S\left(T\right)}\right)
(5)
where S(T) denotes the shadow determined by a threshold T.
S\left(T\right)=\left\{\left(x,y\right)Z\left(x,y\right)<T\right\}
(6)
\overline{Z\cap S\left(T\right)} denotes the mean value of shadow regions in Z; \overline{Z\cap {S}^{C}\left(T\right)} denotes the mean value of the nonshadow regions in Z. The subtraction of them can measure the difference between the shadow regions and the nonshadow regions (the subtraction is always positive, which will be proved in Appendix). The difference between them is weighted by a quadratic function G(T), defined as follows, to avoid too high or too low T.
G\left(T\right)={T}^{2}+2uT
(7)
in which u is the mean value of image Z. The best T should make the mean value of shadow regions and that of nonshadow regions have the biggest weighted difference.
T=\underset{T\in \{N,\mathrm{min}(z)T\mathrm{max}(z)\}}{{\displaystyle \text{argmax}}}\text{{}\zeta (T)\}
(8)
Given T, S can be determined by using Equation (6).
Denoting \kappa =\frac{\overline{X\cap {S}^{C}}\overline{X\cap S}}{\overline{X}} and \eta =\frac{\overline{Y\cap {S}^{C}}\overline{Y\cap S}}{\overline{Y}}, the weight α is defined as:
\alpha ={e}^{\frac{\kappa}{\eta}}
(9)
κ and η measure the contributions of X and Y on getting the threshold. The exponent of \frac{\kappa}{\eta} heightens the difference of the contributions and make sure α > 1 for the following two reasons.

(1)
The range of variation of X is lower than that of Y (as stated above, the TAMbased subtraction will smooth pixel values).

(2)
Shadow detection relies mainly upon X; Y is mainly used to obtain precise result (see Figure 4 and refer to [1]).
α is initialized with \frac{\overline{Y}}{\overline{X}}. Repeating (4)(9) to update T and α until \zeta \left({T}_{\mathsf{\text{new}}}\right)\le \zeta \left(T\right).