Split text by paragraphs / white line

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tecya
Posts: 2
Joined: 2017-06-03T16:08:35-07:00
Authentication code: 1151

Split text by paragraphs / white line

Post by tecya »

Hi, I wanted to split http://i.imgur.com/CWkj5dv.jpg into http://i.imgur.com/vFAFtqh.jpg.
I used the divide_vert script, however it splitted too much.
Reading the TO_DO list in the code I found that the minimun height is planned for a future version.

Can somebody help me?

Maybe the number could somehow be used as a separator?

Thanks

I'm using the latest version of IM. OS are Ubuntu and OS X.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Split text by paragraphs / white line

Post by snibgo »

tecya wrote:I'm using the latest version of IM.
Latest version of v6 or v7? Please say exactly which version.

What divide_vert script? Perhaps the one at http://www.imagemagick.org/Usage/scripts/divide_vert

The required results are obtained from:

Code: Select all

set guilMIN_GAP=20

call %PICTBAT%guillotine CWkj5dv.jpg chop_XX.png White 5 . 1
The script is on my page Subimage rectangles. It is Windows BAT, for IM v6, but fairly easily translated to bash and/or IM v7.
snibgo's IM pages: im.snibgo.com
tecya
Posts: 2
Joined: 2017-06-03T16:08:35-07:00
Authentication code: 1151

Re: Split text by paragraphs / white line

Post by tecya »

Thanks, sadly It didn't work. I also spent 5 hours trying to customize the divide_vert script, but without success
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Split text by paragraphs / white line

Post by fmw42 »

This may be similar to what snibgo suggested. But consider blurring the text, then thresholding, average down to 1 column and then expand back to full size for viewing, then threshold again. This produces a black and white image. The white lines separate your paragraphs. You can then crop to 1 column and send that to txt: format as a list. Then find the locations of the centers of each white area. Then you can draw gray lines at those locations in your original image. Or you can crop your image at each black area to separate each paragraph as its own image and combine as you desire with gray around it.

Code: Select all

convert CWkj5dv.jpg -blur 13x65000 -auto-level -threshold 90% -scale 1x1754! -scale 1240x1754! -auto-level -threshold 90% CWkj5dv_bw.png
Image
Post Reply