Link to home
Start Free TrialLog in
Avatar of tech1guy
tech1guyFlag for United States of America

asked on

Auto Crop/Trim border of image in C#

Hello everyone,
I'm trying to remove the surrounding color from the scanned image. I've a scanned page of book but it comes with some surrounding color (e.g grey color). I am trying to cut just the book page leaving the surrounding color. So, far I've tried GDI+ and AForge but nothing seems to work accurately.

Is it even possible (or I'm trying in vain) to automate the trim of surrounding color from the scanned image in C#?

Kindly suggest and any working link would be great help.

Regards
Avatar of ste5an
ste5an
Flag of Germany image

What are your objectives here? Why not automating Gimp/Paint.net/Photoshop..?
Avatar of tech1guy

ASKER

I wrote a script to take screen shots of running application after every 2 seconds. Now, those screen shots needs to be cropped of the surrounding space within the C# code. I've tried the following link to crop: http://pastebin.com/FADb57fq

but it crops certain images only but not all. I'm not sure what's wrong. Any help would be a boon for me.
How do create the screen shots? Script??
Yes, CopyFromScreen (within a C# method/script) method is used to capture the screen. Basically, screen shots are captured while a certain desktop application is running and it's done for the Audit purposes.
I would use some more low-level style programming to copy just the window I want. Here is a C++ sample showing what steps it needs. Here you'll find a C# wrapper for it: Capture a Screen Shot. And here the same in VBA.
Thanks for the link but I'm stuck at the removing the grey color surrounding each screen shot. I've no problem in taking the screen shot. Could you please suggest something to remove the surrounding color from the image?
I would really reconsider the approach...
That's a good idea. Thanks. But in general removing the surrounding colors from the scanned images would be a nice tool to have. Any ideas on that one?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much for the ideas!