tech1guy
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
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
What are your objectives here? Why not automating Gimp/Paint.net/Photoshop.. ?
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.
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??
ASKER
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.
ASKER
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...
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much for the ideas!