MATLAB: How to rectify images

Computer Vision Toolboximage processingImage Processing Toolboxocrpattern matchingrectification

Hi all,
Interesting problem here. I am working on extracting old Chinese texts which are written in vertical lines, but first I need to rectify the images like:
After rectification:
But originally they can be in whatever shapes like:
The only thing guaranteed is that those characters are arranged in multiple vertical lines.
I tried to use Uncalibrated Stereo Image Rectification ( https://www.mathworks.com/help/vision/examples/uncalibrated-stereo-image-rectification.html ), but problem is that the images are NOT in pair, so I only know the target pattern rather than the exact target.
If anyone can provide hints about useful functions, please let me know. First-step solutions like automatically rotating the image to the right angle will also be helpful!
Thanks a lot!

Best Answer

From what I understand, your two main issues are 1) detecting the text in your images, and 2) perspective correction.
You can refer to the following page on detecting and recognizing text in images:
https://www.mathworks.com/help/vision/examples/automatically-detect-and-recognize-text-in-natural-images.html
As well as this File Exchange submission that gives an example on how to perform perspective correction on a bounded area of text:
https://www.mathworks.com/matlabcentral/fileexchange/35531-perspective-control--correction
(This Wikipedia page might be a good starting point as well)
Related Question