File Exchange

image thumbnail

Straighten image

version (5.34 KB) by Jan Motl
The function finds the document orientation.


Updated 14 Apr 2013

View License

The function is useful for automatic image straightening.

Three different approaches how to find the image orientation were implemented: Fourier transform, Hough transform and region properties.

The principle of using Fourier transformation for orientation detection is well described at:

Hough transformation finds lines in the picture. The description of Hough transformation is at:

In a similar problem, horizon detection, only the longest line determines the image orientation:

However, in text orientation detection it is beneficial to consider all lines' direction to improve signal-to-noise ratio. This late approach is implemented.

Finally region properties binarizes the image and then uses REGIONPROPS from Image Processing Toolbox to calculate blob's orientation.

Cite As

Jan Motl (2020). Straighten image (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Vijay Venkatesh

works for almost all images


thank you.

Victor Grubîi

Sudipto Chaki

Thank you very much. This function works very effectively

aghiad raslan

Farnaz Abtahi

Soumya Panda



Improved text description. Added blob detection.

Added Fast Fourier Transform.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux