Border Detection

Processing of images digitally is of much importance since processes are digitalised and people take picture of different ID cards(driving license, passport etc) and upload for various purpose today(for instance filling online applications and forms for numerous reasons).First level of image processing algorithm is implemented on these images for seamless application processing before they are uploaded in the system due to the presence of various issues in the images like existence of white spaces, skewed image to name a few. In the case study we discuss:

  • Automatic ID card border detection and the image cropping
  • Removal of skewness(if present)
  • Correction of orientation


We used OpenCV library for image processing along with EmguCV wrapper, which is compatible with .NET languages (C#,VB,VC++ etc). We implemented the solution through the following steps:

  • Pre-processing to convert the image to greyscale and reduce the noise and improve image quality and size using PyrDown and PyrUp

Down sample -> Noise reduction -> Up-sample -> Image Enlargement

  • Edge detection using Canny algorithm(to convert image into collection of lines)
  • Detect outermost lines for Border detection through ‘Probabilistic Hough transform’ to filter out lines based on width & length
  • Using ‘FindContours’ to find objects at outer most location (to overcome the shortcomings of Hough transform)
  • Post processing which includes cropping the image along the border and getting a processed image containing ID card completely and removing any skewness present


We encountered some issues as below: 

  • Establishing a pre-defined system criterion which needs to be met before uploading the picture. This includes deciding threshold value for the image processing algorithms to be implemented for removal of white spaces present on the side of ID card and skewness present in the image captured
  • The Canny algorithm used for border detection had some limitations and didn’t work in all the scenarios where ID card had more prominent rectangle drawn on it or an image with white background of a white ID card. These cases didn’t gave a correct collection of lines and may have resulted in incorrect border detection. To overcome this problem we implemented FindContours on binary image which gave us a more reliable result
  • We had to cater for devices of varying power and capability since this solution implementation had to run on various platforms. As we got into the testing phase we had to avoid large variation in responsiveness depending on the device used
Please fill in the details to download the case study.
[contact-form-7 id="3034" title="Case Study"]



An application to capture images using Browser camera based
Ability to detect images and crop and de-skew the imagesDoing OCR of the images Ability to store in Azure blob Storage and extract relevant information to the database

Other Case Studies