Reputation: 31
Am looking for any recommendation for libraries that will allow me to auto orient images. My project is in C#. I am looking for either open source or commercial libraries.
I want to use these libraries on either documents that are scanned or faxed as such my images will be lacking of EXIF data
The image will contain mostly English text. I looked at the OCR that MODI provides, can't go that route as the customer apparently is not running Office 2007.
Upvotes: 3
Views: 1997
Reputation: 1418
It's not a managed solution, but I've had acceptable results using Dan Bloomberg's leptonlib C library, which comes with a VC9 project and an example of using the library from C# via a managed C++ wrapper. It includes an implementation of orientation detection, but I have found its accuracy is only good when the images are mostly mixed-case alpha text in non-uniform layouts (paragraphs and discrete text rather than tables/grids). Using additional preprocessing and heuristic analysis (based on other methods in the same library) I have managed to improve the accuracy on the edge cases as well, though it still only hits around 87% total accuracy on my (fairly large) sample set.
Upvotes: 0
Reputation: 137188
If you don't have EXIF data and your images are scanned/faxed documents then I think you're only solution is to check the height and width of the image and rotate based on that.
Documents are most likely to be in portrait format (taller than they are wide), so if the height is greater than the width then do don't have to do anything.
If the height is less than the width then rotate through 90 degrees. However, without analysing the image in some way you won't know which way to rotate it (left or right) and so could end up with the image upside down.
How many images are there going to be? If there aren't too many you could perform the rotation and then present the image to the user and ask if it's upside down or not. If it is rotate though 180 degrees. Not an ideal solution though.
Upvotes: 0
Reputation: 176259
If you mean to extract the image orientation from the EXIF data and to rotate the image accordingly then you might want to have a look at ImageMagick's auto-orient feature.
You can either automate ImageMagick via the command line or use the available .NET wrapper.
If you don't have EXIF information available, an automatic detection of the orientation will most likely only work if your image contains mainly text in lines (I assume this is the case for faxes). You could then make use of an OCR engine and use the orientation detected by the engine.
Upvotes: 3