Using openCV to remove image background and shadows.
The algorithm used in this repository are largely adapted from this article: http://developers.lyst.com/data/images/2014/02/13/background-removal/
For this implementation, the steps used in shadow and background removal are:
- Remove shadows by converting to HSV and setting V to a fixed value
- Convert to grayscale and normalize
- Apply gaussian blur and Canny edge detector
- Dilate to close gaps
- Flood fill the image from borders
- Erode to account for previous dilation
- Find largest contour
- Mask original image
This method requires the background to be relatively empty and have some contrast with the foreground.
==========================================================