Page 1 of 1
Remove underlines from image for ocr
Posted: 2018-06-20T00:40:17-07:00
by wineismine
I need to remove lines from the following image without affecting the characters
Code: Select all
magick 21.gif -monochrome ( +clone -negate -statistic median 219x1 ) -compose lighten -composite q1.png
To make it more clearI dont want my image to have gaps which are shown in the image below, due to the line removal using the above code

Re: Remove underlines from image for ocr
Posted: 2018-07-04T05:42:38-07:00
by wineismine
anyone?
Re: Remove underlines from image for ocr
Posted: 2018-07-04T06:10:19-07:00
by snibgo
It can be done, but I can't see an easy way.
Each pixel that is removed may have had neighbours in three positions on the previous row (up, up-left and up-right), and neighbours in three positions on the following row.
For some combinations of neighbours, you want to replace the pixel that was removed. For others, you don't.
I don't have enough time to work out the details.
Re: Remove underlines from image for ocr
Posted: 2018-07-04T07:20:26-07:00
by wineismine
snibgo wrote: ↑2018-07-04T06:10:19-07:00
It can be done, but I can't see an easy way.
Each pixel that is removed may have had neighbours in three positions on the previous row (up, up-left and up-right), and neighbours in three positions on the following row.
For some combinations of neighbours, you want to replace the pixel that was removed. For others, you don't.
I don't have enough time to work out the details.
could you give me some example codes to try?
Re: Remove underlines from image for ocr
Posted: 2018-07-04T11:46:53-07:00
by snibgo
Another approach is
Mending broken lines, but mask this so mending occurs only where horizontal lines have been removed.