Abstract

Shadows greatly attenuate the performance of many computer vision algorithms such as object recognition. Removing shadows from video is easy using background subtraction. On the other hand, removing shadows from stationary images is difficult. A significant amount of work is done in this area using 1D invariant images. We took a different approach where in, we first detect the shadow present in the image and then select a small window from the same image to replace the shadow with.

Teaser figure





Introduction

When there are shadows in the images, it interferes with the intended output. For example, an object recognition program may detect false objects due to the shadows present in the image. As, for stationary images, there is no information about what is background and foreground, we cannot easily decide where the shadow is, unlike video frames, where in we can subtract previous frames from the current one to find background.

Recently, a method for removing shadows from color images was developed [Finlayson, Hordley, Lu, and Drew, PAMI2006] that relies upon finding a special direction in a 2D chromaticity feature space. This “Invariant Direction” is that for which particular color features, when projected into 1D, produce a grayscale image which is approximately invariant to intensity and color of scene illumination. Thus shadows, which are in essence a particular type of lighting, are greatly attenuated.

The main approach to finding this special angle is a camera calibration: a color target is imaged under many different lights, and the direction that best makes color patch images equal across illuminants is the invariant direction.

Using a different approach, producing a 1D projection in the correct invariant direction will result in a 1D distribution of pixel values that have smaller entropy than projecting in the wrong direction. The reason is that the correct projection results in a probability distribution spike, for pixels all the same, except differing by the lighting that produced their observed RGB values and therefore lying along a line with orientation equal to the invariant direction.

The approach we have taken involves detecting shadows in the image first and then change the R,G,B values of the pixels such that it is as illuminated as the rest of the image.

Approach

  1. Convert the image from RGB space to LAB space, where L is lightness component and, A and B are color-opponent dimensions, based on nonlinearly compressed coordinates.
  2. The L channel has values ranging from 0 up to 100, which corresponds to different shades from black to white. Since the shadow regions are darker and less illuminated than the surroundings, it is easy to locate them in the L channel since the L channel gives lightness information.
  3. Then we create a shadow mask by thresholding.
  4. Equation3
  5. We take the input from the user regarding how many shadows the user want to remove. Based on the input i.e. number of shadows to be removed, the user is asked to select a shadow region. Region Growing is used to get the desired shadow mask from the image.
  6. Then the user is asked to select a small non-shadow from the image. This is used as the desired RGB model based on which we perform shadow removal.
  7. Shadow removal is done by multiplying R, G and B channels of the shadow pixels using appropriate constants. The ratio of the average intensities of pixels in each channel in the selected non-shadow region to that in the shadow region is taken as a constant for each channel. The shadow regions achieve almost the same illumination as the non-shadow regions. Least Squares method is used to reduce the error in constant estimation.
    Equation6
    Where P is the region outside the shadow, S is the shadow region, c is the constant that the shadow region is multiplied by.
  8. Also, we know that outdoor shadows are caused by an object occluding sunlight. We can then further constrain c to
  9. Equation7
  10. Since shadow regions are not uniformly illuminated, the same constant for the entire shadow region will create over-illuminated areas near the shadow edges. This is overcome by applying a median filter on the over-illuminated areas. Thus a shadow-free image without over-illuminated edges is obtained.


Experiments and results

First we tried to get shadow free images using 1D invariant. The main difficulty with 1D invariant is, after projecting the image in invariant direction, the results are not as promising as that are given by the Original Image. By Original Image, we mean processing the very same image that was captured by camera. When the image is resized or modified or some how the information is lost, the projected Invariant will not be so accurate and it will be noisy. To recover the shadow free image from this noisy Invariant is a difficult task.

Here are some results of the Invariant image that we obtained from the images taken off the internet and copied from the pdf file:

We have limited our inputs to outdoor images which have shadows caused by an object occluding sunlight. The algorithm works better with objects that are not dark in comparison to the shadow region. Also, the user is required to select a desired non-shadow region. As a consequence, results may vary subject to the user’s visual interpretation of the properties of the non-shadow region.



Qualitative results

The shadow removal technique proposed in this project gives fast results and does not need multiple images or camera calibration. A drawback with this approach is that the dark objects may be misclassified as shadow areas and shadow edges require a good amount of filtering.

Here are the results we obtained for some test images.

Figures (clockwise from top): Original Image, Shadow Image, Image Without Shadow, Image with artifacts at the edge of the shadow.

Image 1:


Image 2:


Image 3:


Failure Case:




Conclusion and Future Work

The whole idea of removing shadows is based on the premise that the lightness component in the image is separate and not associated with the chromaticity component. The proportion of R:G:B is same in the whole image irrespective of the lighting conditions. If we can find what is the ratio of the R,G,B values where there is no shadow and the ration of the same inside the shadow, we can change the ratio of R:G:B inside the shadow region to that of the R:G:B outside the shadow region. Also, this argument is based on the assumption that there are some chromaticity values captured in the shadow region. If the shadow region is so dark that there are no chromaticity values captured by the camera for that region, there is no way for us to determine what colors are there in the shadow region. In which case the algorithm fails.

References