Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Rotate an image so that dominant lines are horizontal
ResourceFunction["ImageLineLevel"][img] rotates image img so that dominant lines are horizontal. | |
ResourceFunction["ImageLineLevel"][img,n] rotates image img so that dominant lines are horizontal using an EdgeDetect radius of n to find lines. | |
ResourceFunction["ImageLineLevel"][img,n,t] rotates image img so that dominant lines are horizontal using EdgeDetect radius n and threshold t to find lines. |
Background | 0 | background color to use |
Masking | All | region of interest |
Method | Automatic | EdgeDetect method to use |
Padding | 0 | padding of the original image |
Resampling | Automatic | resampling method |
Rotate an image so that its horizon is level:
In[1]:= |
Out[1]= |
Where lines are not strong compared to texture, ImageLineLevel can fail to find the important lines:
In[2]:= |
Out[2]= |
Using the radius and threshold settings, as described for EdgeDetect, allows for better control of line detection:
In[3]:= |
Out[3]= |
All options of ImageRotate and EdgeDetect are supported. For example the rotated image can be padded with reversed image contents:
In[4]:= |
Out[4]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License