{'fraction_non_alphanumeric': 0.026643835616438356, 'fraction_numerical': 0.007671232876712329, 'mean_word_length': 4.752955082742317, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Shadow detection on color images

The shadow areas cause significant problems in objects recognition and classification applications. The shadows have uniform properties in some colour spaces. Thus, the shadow detection can be effectively done by applying the threshold processing. This paper proposes a simple method to detect shadows in images using the combination of two components from different colour spaces. The B component of LAB colour space is used to detect homogenous areas using contour segmentation algorithm. The method uses the V component of HSV colour space to decide whether the obtained areas (the result from the segmentation stage) are shadowed or not. This stage is done using the mean value of the V component for these areas and subsequent thresholding based on Otsu’s method. The experimental results show that the proposed approach can get accurate detection results like the state-of-art-methods, while it is more stable for the difference of characteristics of initial images.


Introduction
Shadows degrade the quality of image segmentation and pattern recognition in decoding and analyzing of remote sensing images. Shadows areas are seriously different in intensity from their surrounding areas and have an edge with object caused them. Most of the algorithms detect a shadow as an individual segment. It causes objects' shape distortions getting them difficult to recognize. In the application of road detection, objects may be partially obscured by shadows which disable the objects detection on that part of the road.
Therefore, the technology of shadow detection and removal is a hot research topic and is widely discussed in the literature.
Different methods of original image transformations are used for shadow removal [1,2], such as linear correction, gamma correction and histogram matching, etc. They balance the pixel intensities in the shadow regions and in the light region. However, the application of such transformations to the entire image changes characteristics of objects on it's, such as colour or brightness. This may adversely affect the further classification of objects. Therefore, it is more effective to process shadows in two stages. The initial stage in the elimination of shadows from an image involves shadows detection. At the second stage, the characteristics are transformed only within the shadowed areas.
There are two types of shadow detection method: methods based on a surface model [2][3][4][5] and methods based on properties [6][7][8][9][10]. The first group of methods requires a priori knowledge of the surface of the analyzed area. These methods employ the surface model and the location of the light source to calculate positions of shadows. The accuracy of shadow detection is generally high for this category of methods. However, these methods require large computational time and prior knowledge, which is not always available in real conditions, especially for near real-time systems.
The second group of shadow detection methods does not need other information except an origin image. Feature-based methods extract information about localization of shadows from the original image using different transformations. These methods widely apply threshold processing, colour space conversion, algorithms of region growing, clustering, and classification [6][7][8][9][10][11].
Feature-based methods are simpler and faster than model-based methods. Moreover, these methods do not require high computational resources and prior knowledge; because of this, they are applied more commonly.
This paper proposes a simple shadow detection method based on using the combination of components of different colour spaces. This method provides a high quality of shadows detection for images with different characteristics due to the pre-segmentation of the original image into homogeneous areas.

The properties of shadows in different colour spaces
Many approaches for shadow detection convert the original RGB image to other colour spaces. In several colour spaces, shadows have more pronounced features and can be detected more efficiently. The known works use such colour spaces as LAB [6], HSV [7], HSI [8][9][10], c1c2c3 [7,12], and their combinations [7]. We compared the mean values of the shadow areas with the mean values of the nonshadow areas in different components to make a reasonable choice of colour space. Table 1 summarizes the results of this comparison for three test images, which are shown in figure 1. Here S mean is the mean value of a component for shadow areas, NS mean is the mean value of a component for non-shadow areas.  3 saturation (S), and value (V) or intensity (I). They are given in table 1 in normalized form, that is, they can take values in the range from 0 to 1.
The c1c2c3 colour space [13] is computed from the RGB representation through the following nonlinear transformations: From table 1, we find that the pixels in the shadow areas have lower values than in the non-shadow areas for all three components of the RGB colour space. However, the values of these components have significantly different values for different images and depend on the colour of the shaded object.
The pixel values in the shadow areas of the H and S components are higher than in the non-shadow ones. However, different images have significantly different values of these components in the shadow areas. The components of brightness and lightness (V, I, L) always have lower values in the shadow areas than in the non-shadow ones. Moreover, they have the same values of shadow areas in all images. On the components A and B of the LAB colour space the values in the shadow areas and in the non-shadow areas differ slightly, as well as for the c1c2c3 colour space. The components c1 and c2 have mostly lower values in the shadow areas, but the component c3 has higher values.
Thus, the values of the shadow areas on the V, L and I components are more invariant to the type of the original image. Many methods based on features work well on some type of images and show unacceptable results on images with other characteristics because of different image characteristics. Therefore, using the combination of components from different colour spaces will increase the stability of the shadow detection method.

Proposed shadow detection method
Most feature-based methods for shadow detection use threshold segmentation. One or several components of a selected colour space or a characteristic obtained as a result of their transformation can be used as a feature for segmentation. The first stage of the proposed method is the presegmentation of one colour component. As a result of segmentation, the original image is divided into homogeneous regions. Then the mean value of the feature is calculated for each obtained segment using a different colour component. This mean value is used to decide whether the segment is a shadow or not. We experimentally found that the best results can be obtained using the B component of the LAB colour space for pre-segmentation and the V component of the HSV colour space for calculating features. Figure 2 shows the block diagram of the proposed approach.
At the pre-processing stage, the original image is converted from RGB colour space to HSV and LAB colour spaces. The B component is used to detect homogeneous segments in an image. Here we use the contour segmentation method proposed in [14]. As a result, we obtain the contour image containing the boundaries of homogeneous regions.
At the next stage, the mean value of the V component is calculated for each segment within the obtained boundaries. As a result, all pixels of a segment have the calculated feature value.
After this, we decide whether each segment is shadow region or non-shadow region by comparing with a threshold. If the feature of a segment is less than the threshold then it is shadow region and if it is greater than the threshold then that segment is non-shadow region. The image obtained after this thresholding will be a binary mask with all shadow pixels set to white colour and all non-shadow pixels are set to black colour. Figure 3 shows the sequence of transformation of the test image after each stage. Figure 3 (a) is the original image. Figure 3

Experimental results
We evaluate the proposed method on test images obtained from an open data set SBU Shadow Detection Dataset [15] with Matlab program. All experiments were done on a personal computer with an Intel Core i7 3,4 GHz CPU and 4 GB RAM.
Since the proposed approach uses threshold processing to separate the shadow and non-shadow regions, we evaluate how the threshold selection affects the performance of the method. The threshold can be set manually as a constant value for all images or calculated automatically for each image. Finding the optimal threshold is a difficult task. We conducted several experiments in which we compared the quality of shadow detection at different values of the constant threshold, as well as when the threshold is selected automatically using the Otsu's method [16].
We have chosen metrics based on comparing the computed shadow mask with the ground truth mask on a pixel by pixel basis to evaluate the correctness of shadow detection results. The ground truth masks were obtained from SBU Shadow Detection Dataset [15].  Figure 4 shows the results of shadow detection for a range of values of a threshold in terms of the F-measure, OA and MCC metrics for a test image.
From this figure, we can highlight that plots for all metrics are stepped. Therefore, there is an optimal interval of the threshold values, where metrics have the highest values. In this interval, the threshold value can vary without affecting the quality of shadow detection. We can select any threshold value from this interval, and this will give us the same result.
We test other different test images and received the same results. But the optimal interval of threshold values for different images is in different range. Table 2 shows the quality of the proposed method for different threshold selection approaches. The values in table 2 are averaged over 60 test images. We have compared three approaches. The first is the optimal threshold, which is individually calculated for each image. The second approach is the automatic threshold selection based on Otsu's method. In the last experiment, we use a single constant threshold for all images, which is calculated as the mean value of the optimal thresholds of the test images.
We can see that using the single constant threshold have the lowest quality. The Otsu's method is slightly inferior in quality to the optimal threshold. But the difference of the metrics is small (for Fmeasure is 0,065; for OA is 0,024; for MCC is 0,052). Moreover, Otsu's method is automatic and fast. Thus, we can use Otsu's method to the threshold selection without significantly reducing the quality of shadow detection.

Comparison with existing methods
We have compared the quality of the proposed method against the existing algorithms. We have chosen methods based on properties, such as methods proposed by Tsai [8], Mamde [9], Singh [10], Murali [6], Arevalo [7].
Tsai presented a method which uses two components (H and I) from the HIS colour space. He also calculated the spectral ratio (5) in each pixel of an image. Pixels in shadowed regions have higher values in RI than pixels in non-shadowed regions. Otsu's method is then applied to determine the threshold for segmenting the regions into a binary mask. The obtained binary mask is processed using morphological filtering.
= ( + 1) ( + 1). ⁄ (5) The method proposed by Mamde is the modification of Tsai's method. The difference lies in the transformation of the original RGB image into the grey image. Then the global thresholding scheme using Otsu's method is applied. Finally, threshold processing and morphological filtering are used to create a shadow binary mask.
The method proposed by Singh also is based on the HSI colour space, but shadows are detected using normalized difference index NDI (6): = ( − ) ( + ). ⁄ (6) A positive threshold can be found to segment the NDI image using Otsu's thresholding algorithm. The image pixels which have a higher NDI than the threshold are accepted as shadow pixel; otherwise not.
In the method proposed by Murali, the LAB colour space and threshold processing are used. The mean values of the pixels in L, A and B components of the image are calculated separately and condition (7) is checked. If it is met, the pixels classified as shadow pixels if the condition (8) is met. If the condition (7) is not met, the pixels classify using the conditions (9). Morphological filtering is applied after thresholding to eliminate local inhomogeneities. The combination of the components from HSV and c1c2c3 colour spaces is used in the method proposed by Arevalo.
The magnitude of gradient of the intensity image (V component) is computed by Sobel detector. For segmenting the shadows, the region growing process is applied over the c3 component. The initial centres of the regions and the decision to add a pixel to the region are made on the bases of the S, V, c3 components and the threshold processing. The thresholds in the method are set a priori and have been found empirically. Figure 5. Comparison of the shadow areas detected by different methods.  The resulting shadow mask for our proposed approach is shown in figure 5 (h). Table 3 shows the values of the quality criteria averaged over 60 test images. Table 3 summarizes both the mean value of the criteria (mean), as well as the value of standard deviation (std), which illustrates the degree of variation of the quality criteria for a set of images.

Conclusions
Using colour space conversion and threshold processing is effective for shadow detection. Because of applying pre-segmentation, the resulting shadow areas are more homogeneous and there are fewer single incorrectly detected pixels on the binary mask. This is confirmed by the results shown in figure  5 (h). The observation made out of the experiments is that different methods show the best detection results for images with different characteristics. On average, the Murali's method using the LAB colour space showed the best quality for all criteria. The proposed approach is slightly inferior to Murali's method in term of quality. Besides, it provides a smaller variation in quality criteria for a set of images.
Thus, using the shadow detection approach proposed in this paper it is possible to accurately identify shadows for most images.