how to crop an image id-card only ..?

1 view (last 30 days)
Malta
Malta on 11 Nov 2013
Commented: Walter Roberson on 12 Nov 2013
how to crop an image id-card only ..? using regionprops.

Answers (2)

Walter Roberson
Walter Roberson on 11 Nov 2013
First you threshold based on brightness. regionprops() and look for the one with the largest Area. Fill the inside of the pixel boundaries for that. The result will be a mask that you can use to extract the ID card from the color image.
  5 Comments
Image Analyst
Image Analyst on 12 Nov 2013
If by fixed you mean always in the same location, it does not matter. regionprops() will find the blobs in the binary or labeled image regardless of where they are locataed in the image, or how they are oriented.
Walter Roberson
Walter Roberson on 12 Nov 2013
And also regardless of if they are a constant size.
What you do need to worry about is the thresholding method, if they can be different colors. You are, for example, likely to have problems with a pure black ID-card that lights up in black with black letters.

Sign in to comment.


Image Analyst
Image Analyst on 11 Nov 2013
Get a monochrome image, for example by looking for white, if the cards are always white. Then threshold and find the largest white blob. This is done in my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/25157-image-segmentation-tutorial-blobsdemo
If you want to get a perfect rectangle from the blob, get the filled object and then use http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!