Patern Recognition

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
w.c
Posts: 2
Joined: 2011-05-27T11:11:45-07:00
Authentication code: 8675308

Patern Recognition

Post by w.c »

Hi, I'm new with ImageMagick,
I want to recognize a Black / White pattern from several TIFF files
The file has some regions with Hand writing and (Black) and spaces between each paragraph.
Image
I want to determinate how many paragraphs has the image, The best way I thought was ising the im_profile Script from here
http://www.imagemagick.org/Usage/scripts/im_profile and then count the the Blank Spaces.
However is not quite simple, according to the image.

How I can pre process the image to get this working?
There is other way to get this result?
Can somebody help me?

Thanks a lot
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Patern Recognition

Post by fmw42 »

try this. it should make a binary image with white for the paragraphs and black elsewhere. does that help.


convert 014092021H_example.png -alpha off -statistic maximum 5x5 \
-fuzz 3% -fill black +opaque "rgb(198,181,181)" \
-fill white -opaque "rgb(198,181,181)" 014092021H_example_test1.png

And this will convert the above into a profile

convert 014092021H_example_test1.png -scale 1x373! -rotate 90 MIFF:- |\
im_profile - 014092021H_example_test1_profile.gif

Note the above is on Linux/Mac (Unix). Windows commands are somewhat different and im_graph script is bash shell script. For windows users see IM differences at http://www.imagemagick.org/Usage/windows/
w.c
Posts: 2
Joined: 2011-05-27T11:11:45-07:00
Authentication code: 8675308

Re: Patern Recognition

Post by w.c »

I really appreciate your help and experience
I'll try and I post the result here, maybe this can help Others

After running the command
convert: unrecognized option `-statistic' @ error/convert.c/ConvertImageCommand/2688.

Ubuntu 10.10
ImageMagick 7:6.6.2.6-1ubuntu1.1
Installed from the repository

Thanks for your help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Patern Recognition

Post by fmw42 »

your IM version is too old. there is no such version as 7:6.6.2.6 and so you probably mean 6.6.2.6. The -statistics came at version 6.6.9-3. However, you can do the same with -morphology dilate square:1 should be the same as -statistic maximum 3x3. Othwise upgrade your IM version.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Patern Recognition

Post by fmw42 »

your IM version is too old. there is no such version as 7:6.6.2.6 and so you probably mean 6.6.2.6. The -statistics came at version 6.6.9-3. However, you can do the same with -morphology dilate square:2 should be the same as -statistic maximum 5x5. Note morphology was undergoing changes and improvements, but should be ok for your release. However, you can check the changelog for more details at http://www.imagemagick.org/script/changelog.php. Othwise upgrade your IM version.


convert 014092021H_example.png -alpha off -morphology dilate square:2 \
-fuzz 3% -fill black +opaque "rgb(198,181,181)" \
-fill white -opaque "rgb(198,181,181)" 014092021H_example_test1.png
Post Reply