AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Auto crop scaned image

The forum is to discuss topics related to different areas of image processing and computer vision.

Auto crop scaned image

Postby sbsen » Thu Jun 30, 2011 12:18 pm

Hi All,
I am trying to crop a scanned document from a white background.
I tried different edge detection methods which didn't mark the border of the image, but it was marking some inner parts of the image
Am I missing any things?

I have attached the image, please help

Thanks,
sbsen.
Attachments
art_d.jpg
Attached sample file
art_d.jpg (14 KiB) Viewed 8708 times
sbsen
 
Posts: 3
Joined: Tue Jun 21, 2011 12:46 pm

Re: Auto crop scaned image

Postby andrew.kirillov » Mon Jul 04, 2011 10:44 pm

Hello,

For an image like the attached one, it would be too simple to make auto crop ....
1) grayscale image;
2) binarize it - use Otsu for example;
3) invert it - so you have black background;
4) now use blob processing routine. If you use AForge.NET framework, then look for BlobCounter - it will give coordinates of the scanned object. Use those coordinate for cropping original image.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Auto crop scaned image

Postby sbsen » Fri Jul 08, 2011 5:55 am

Thanks will try and update...
sbsen
 
Posts: 3
Joined: Tue Jun 21, 2011 12:46 pm

Re: Auto crop scaned image

Postby sbsen » Mon Jul 11, 2011 6:42 am

Thanks Andrew
It worked...
1)Scanned image(Orginal)
2)Take a copy of the orginal image(Dup)
3)Dup apply Threshold Filter 240
4)Dup apply Invert Filter
5)Dup apply Blobcounter GetObjectsRectangle
6)Cropping Bitmap.Clone the Orginal image with Rect from Step 5

Thanks...
sbsen
 
Posts: 3
Joined: Tue Jun 21, 2011 12:46 pm




Return to Image Processing and Computer Vision

cron