Page 1 of 1
Syntax ^< create trouble on Mac Osx
Posted: 2014-09-15T08:57:17-07:00
by pietrob71
I'm testing ImageMagick for image preprocessing before pass them to an OCR software.
At the end of the cicle, the software I'm developing will be compiled cross platform (win/lin/mac); my software will launch ImageMagick on different platform through a shell command.
The images that ocr have to recognize contain a grid, therefore the OCR doesn't capture the text inside the grid.
After I've googled for searching a solution, I've find some syntax and now I'm trying to set them for my scope: lines grid removing.
This is the syntax on windows; it works correctly and remove vertical and horizontal lines with a lenght>100 pixel.
Code: Select all
convert test.jpg -negate -define morphology:compose=darken -morphology Thinning Rectangle:1x100+0+0^< -negate test1.jpg
The same syntax runned on Osx, returns an error like this:
Code: Select all
./convert test.jpg -negate -define morphology:compose=darken -morphology Thinning Rectangle:1x100+0+0^< -negate test1.jpg
-bash: -negate: No such file or directory
What's wrong? How can I use this syntax on Osx?
Thanks in advance
Sincerely
Pietro
Re: Syntax ^< create trouble on Mac Osx
Posted: 2014-09-15T09:43:56-07:00
by fmw42
try double quotes around the whole rectangle: expression or just use escapes as \^\<
Re: Syntax ^< create trouble on Mac Osx
Posted: 2014-09-15T09:57:49-07:00
by snibgo
Rectangle:1x100+0+0^<
In Windows, "^" is the escape character. The Windows command interpreter sees this, and passes the next character "<" as a literal to IM, instead of interpreting it as file redirection.
You don't want "^" on non-Windows platforms. You might substitute the appropriate escape character, thus:
Rectangle:1x100+0+0\<
Re: Syntax ^< create trouble on Mac Osx
Posted: 2014-09-15T10:02:46-07:00
by fmw42
Sorry I missed the fact that he was starting from Windows. IM uses ^ for rescaling and in windows would need to be ^^, where appropriate. I mistakenly thought he was using ^ in that manner. So snibgo is correct, if all you want is <, then in unix, leave off the ^ or replace with \.
Re: Syntax ^< create trouble on Mac Osx
Posted: 2014-09-16T00:35:38-07:00
by pietrob71
snibgo wrote:Rectangle:1x100+0+0^<
In Windows, "^" is the escape character. The Windows command interpreter sees this, and passes the next character "<" as a literal to IM, instead of interpreting it as file redirection.
You don't want "^" on non-Windows platforms. You might substitute the appropriate escape character, thus:
Rectangle:1x100+0+0\<
I tried replacing the escape character on windows "^" with the one for non-windows platform "\" and now works fine also on mac osx.
Thank you very much.
Pietro
Re: Syntax ^< create trouble on Mac Osx
Posted: 2014-09-16T02:52:59-07:00
by pietrob71
Into the documents scanned that I will pass to the OCR, I have also some dotted lines (vertical and horizontal).
Is there a way to remove them?
I'm thinking to a process like this:
apply to the original image a -motion-blur 0x4+0 and create an image_horizontal_blured.jpg
apply to the original image a -motion-blur 0x4+90 and create an image_vertical_blured.jpg
At that point, will be necessary to use some command to recognize the horizontal lines area in image_horizontal_blured.jpg, and fill of white this area in the original image creating an image as image_without_hori_lines.jpg.
So do another time the same operation recognizing the vertical lines area in image_vertical_blured.jpg, and fill of white this area in the image_without_hori_lines.jpg creating an image as image_without_vert_hori_lines.jpg.
Would be this approch correct? If yes, can someone help me to do that?
Is there a different way to remove dotted lines?
I think this argument is a very common problem in preprocessing image for OCR and could be interesting for other ones find a post to use as guide.
Thanks in advance
Pietro
Re: Syntax ^< create trouble on Mac Osx
Posted: 2014-09-16T08:18:58-07:00
by snibgo
Fred recently answered an almost identical question, giving a script to remove vertical and horizontal lines. A search should find it.