1

I have a ton of pdfs scans that I have converted to images. Most of these scans contain a lot of whitespace around the edges.

What is the best way to go about finding a boundingbox for the actual content and then subsequently removing the whitespace?

I've thought about writing a program that just displays the image, then you drag a box and its saves the image, and moves on to the next one. This would be VERY time consuming, but it would get the job done. I'd like to be able to automate this process somehow using C#.

Either buy just cropping the image or by perhaps by suggesting a bounding box.

Gabe
  • 11
  • 1
  • It's not hard to write a function that walks an image from the edges-in looking for pixels that are darker than a certain threshold. Is that not what you're looking for? – Gabe Dec 06 '10 at 00:00
  • http://stackoverflow.com/questions/500069/c-gdi-edge-whitespace-detection-algorithm (Detect X/Y X2/Y2) using unsafe gdi+ – Elijah Glover Dec 06 '10 at 00:05
  • The algorithm described here can possibly help: https://stackoverflow.com/questions/24407410/how-to-get-difference-between-2-images-and-save-it-to-an-image – Richard Aubin Mar 31 '18 at 02:21

3 Answers3

0

Emgu CV (on SourceForge) is a .NET wrapper around OpenCV, which has numerous image manipulation capabilities, including image filters and a bounding box algorithm that could solve this pretty easily.

dahlbyk
  • 75,175
  • 8
  • 100
  • 122
0

http://code.google.com/p/aforge/

Aforge is a complete C# library Not a wrapper. OpenCV is very professional tool in compare of AForge.

0

Are you talking about scanned documents or scanned photos ? What format are your images in ? It sounds like you need an AutoCrop function.

Here is a freeware C# component that has an autocrop function. It should work well on B/W documents. You will need to see if it works the way you want if you are using photos.

http://www.hi-components.com/nievolution_features.asp

This component would also allow you to write code to load your images, draw a bounding box and and then save the cropped images as needed.

Andrew Cash
  • 2,321
  • 1
  • 17
  • 11