TomStog / curved-text-alignment

A function that takes as input a cropped text line image, and outputs the dewarped image.
16 stars 3 forks source link

Correcting incomplete curvature #4

Closed josef821 closed 7 months ago

josef821 commented 8 months ago

i try to fix this this curve image: output png_tresh

it found red line very good: Screenshot 2024-03-17 175241

this is output image: Screenshot 2024-03-17 175248

The algorithm you wrote needs some changes due to the large curvature. In fact, the middle of the curve is correctly smoothed( "S" character was uncurved correctly), but the left and right sides are not smoothed well. In an article titled "Alignment of Curved Text Strings for Enhanced "OCR Readability" worked like this. Can you make changes like this? Screenshot 2024-03-18 130251

TomStog commented 8 months ago

My project was developed for a competition hosted by a technology company, focusing on the processing of scanned documents. These input images consisted exclusively of text lines, featuring only slight curvatures, like the one featured at the "Greek Text Example" section.

josef821 commented 8 months ago

Do you have a plan to fix this problem? Or do you not intend to develop this program? I am writing an OCR and your program is very important to me. Only if you can draw a spline like the last photo and make the curve based on the spline, it would be great.

TomStog commented 8 months ago

Hold up, you' re talking about a commercial OCR app/program ?

josef821 commented 8 months ago

No. For my university project for my bachelor's degree, I chose the subject of OCR and I am examining the challenges that arise in creating this program and I am doing it practically to present to my professor. I tested different algorithms, but none of them were as fast and good as your algorithm. But this problem that I said exists in it and it would be great if you could solve this too so that I can put the name and link of your project in my project. The code you wrote can be useful for many people and is a good source for solving the problem of curvature in images. It is also a very good resume for you.

TomStog commented 8 months ago

What you're describing is advanced image processing/dewarping, a field I'm not able to study right now because I'm in the middle of my PhD in a different subject. I'm sorry but I can't be of assistance at the time being. I wish you all the best for your project.

TomStog commented 7 months ago

sports sports_output sports_output_final

TomStog commented 7 months ago

I'll spend the next few days polishing the code before finally uploading it. If you are interested, you can help me optimizing it.

josef821 commented 7 months ago

it's very good. thanks but i'm not professional like you in computer vision and ai. But I am proud to be able to help. how can i help? share code to check.

TomStog commented 7 months ago

The code and the "sports.png" image have been uploaded. It's not optimized yet and there are some parameters that are manually changed. That's the next step in order to fully automate it.

josef821 commented 7 months ago

did you do this with "Alignment of Curved Text Strings for Enhanced "OCR Readability" article? or you create your own algorithm? explain to solve it together

TomStog commented 7 months ago

It is an algorithm of my own. I start with the red line and for every point I calculate perpendicular points to the estimated curve. Something like this : Figure_1

Then using Bresenham's line algorithm, connecting the two perpendicular points, I take all the in-between pixels and use them to create the new image. Finally, I use my old standard algorithm to straighten any deformations.

Overall, it's like scanning up and down across the estimated curve.

josef821 commented 7 months ago

greate. i working on source code and check them line by line. seems i need much more time than you 😄