Determine portrait or landscape format

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
SAFmajo
Posts: 2
Joined: Fri Jul 03, 2015 12:00 pm

Determine portrait or landscape format

Post by SAFmajo » Fri Aug 25, 2017 11:27 am

Dear all,

we have some scanjobs that have mixed layout formats (portrait and landscape). Is there a way while acquiring each page to determine if the current scanned page is either landscape or portrait formatted (distinguished by text orientation or whatever kind of "magic") ?

many thanks for ideas or hints

Best regards

majo

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Determine portrait or landscape format

Post by Loïc » Fri Aug 25, 2017 3:55 pm

Hi,

Your best bet is this wonderful feature: https://www.gdpicture.com/guides/gdpicture/web ... ation.html

Please let me know if you need further info.

With best regards,

Loïc

jamesmi
Posts: 1
Joined: Tue Jan 15, 2019 6:51 pm

Re: Determine portrait or landscape format

Post by jamesmi » Tue Jan 15, 2019 6:55 pm

Very helpful topic. Thanks a lot for that. I emphasize for me so much details to use in my job.
By the way, before that I found several good ideas on the site http://fixthephoto.com/ . If you have free time please check it and describe what do you think.
Best wishes
James
Last edited by jamesmi on Thu Jan 24, 2019 11:17 am, edited 1 time in total.

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: Determine portrait or landscape format

Post by Gabriela » Thu Jan 17, 2019 2:14 pm

Hello,

Now a new class is available dedicated to the OCR functionality in GdPicture from version 14.0.28:
https://www.gdpicture.com/guides/gdpicture/web ... reOCR.html
The above-mentioned GetOrientation() method you can find here:
https://www.gdpicture.com/guides/gdpicture/web ... ation.html
Here you can find an example of usage:
https://www.gdpicture.com/guides/gdpicture/web ... 20OCR.html

timothy15
Posts: 1
Joined: Tue Sep 26, 2023 12:42 pm
Contact:

Re: Determine portrait or landscape format

Post by timothy15 » Tue Sep 26, 2023 1:00 pm

Determining whether a scanned page is in portrait or landscape format is a common challenge in document processing, especially in applications like OCR (Optical Character Recognition) or document management systems. There are several techniques you can employ to make this determination, and it often involves analyzing the content and orientation of the text on the page. Here's an elaborate explanation of how you can approach this problem:

Text Orientation Analysis:

One of the most reliable ways to determine page orientation is by analyzing the orientation of the text on the page. Text is typically written horizontally in portrait mode and vertically (or at a significant angle) in landscape mode.
You can use text detection algorithms to identify text blocks on the scanned page and calculate the predominant angle of the text. If the angle is close to 0 or 180 degrees, it's likely in portrait mode. If it's close to 90 or 270 degrees, it's likely in landscape mode.
Edge Detection:

Another approach is to perform edge detection on the scanned image. In portrait mode, the long edges of the page are typically horizontal, whereas in landscape mode, they are vertical.
By detecting lines in the image and analyzing their orientation, you can determine whether the page is in portrait or landscape format.
Page Aspect Ratio:

Calculate the aspect ratio of the page. In portrait mode, the aspect ratio will be taller (height > width), while in landscape mode, it will be wider (width > height).
Set a threshold aspect ratio value to classify pages as portrait or landscape.
OCR Analysis:

Run OCR on the scanned page to extract text. OCR engines often provide information about the orientation of the recognized text.
If the OCR results indicate that the text is predominantly oriented horizontally, it's likely a portrait page. If it's vertical, it's likely a landscape page.
Machine Learning:

Train a machine learning model (e.g., a Convolutional Neural Network or CNN) on a labeled dataset of scanned pages with known orientations.
Use features such as text density, text angle, or prominent visual elements to classify new pages into portrait or landscape.
User Input:

Sometimes, user input or metadata associated with the scanned document can provide clues about its orientation. If the scanning application allows users to specify the orientation, this information can be used.
It's worth noting that a combination of these methods may be the most reliable approach, as no single method is foolproof in all scenarios. Additionally, image preprocessing (e.g., deskewing) may be necessary to improve the accuracy of orientation detection.

Implementing these techniques will require image processing work and text analysis tools or libraries, and the choice of method may depend on the specific requirements and constraints of your scanning and document processing system.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest