Help with MagickMorphologyImage for thinning.
Posted: 2010-06-10T16:53:12-07:00
Hi,
A bit new here and have been using MagickWand trying to get some images ready for OCR. I have had my own hit and miss algorithm working separately getting the raw image data from MagickWand and converting it. Today I noticed MagickMorphologyImage which isn't in my build so I've built from source and am trying to get my head around how to go about doing what I want. As far as I can tell I need to use ThinningMorphology as the MorthologyMethod argument and the 'Type 10' KernelInfo mentioned here:
http://www.imagemagick.org/api/morphology.php
Can somebody clarify with a snippet how this should be done. Something like:
/* Apply Morphology */
KernelInfo l_KI=AcquireKernelBuiltIn('Type 10',-1);
MagickMorphologyImage(morph_wand,ThinningMorphology,2,&l_KI);
Etc. would be useful. Yes I know the above is completely wrong. Think of it as a kind of pseudo code. For what it's worth though if you do try to compile the above you get:
jpegtobw.c:116:40: warning: character constant too long for its type
jpegtobw.c: In function ‘ConvertJPEGtoBWArray’:
jpegtobw.c:116: warning: passing argument 2 of ‘AcquireKernelBuiltIn’ makes pointer from integer without a cast
/usr/include/ImageMagick/magick/morphology.h:126: note: expected ‘const struct GeometryInfo *’ but argument is of type ‘int’
jpegtobw.c:116: error: invalid initializer
Are there any pointers? Searching the web for these functions simply gives the C and Header documentation found here and on mirrors. Thanks in advance.
**EDIT**
I have something that compiles with this:
/* Apply Morphology */
MorphologyMethod l_MM=ThinningMorphology;
KernelInfoType l_KIT=FreiChenKernel;
struct _GeometryInfo l_GI;
l_GI.rho=0; l_GI.sigma=0; l_GI.xi=0; l_GI.psi=0; l_GI.chi=0;
struct KernelInfo *l_KI;
l_KI=AcquireKernelBuiltIn(l_KIT,&l_GI);
MagickMorphologyImage(morph_wand,l_MM,2,l_KI);
but it does nothing appreciable. Any pointers? Other wand functions like Quantize and the Sigma Threshold Pixel iterator example in the docs are working aok.
Diziet
A bit new here and have been using MagickWand trying to get some images ready for OCR. I have had my own hit and miss algorithm working separately getting the raw image data from MagickWand and converting it. Today I noticed MagickMorphologyImage which isn't in my build so I've built from source and am trying to get my head around how to go about doing what I want. As far as I can tell I need to use ThinningMorphology as the MorthologyMethod argument and the 'Type 10' KernelInfo mentioned here:
http://www.imagemagick.org/api/morphology.php
Can somebody clarify with a snippet how this should be done. Something like:
/* Apply Morphology */
KernelInfo l_KI=AcquireKernelBuiltIn('Type 10',-1);
MagickMorphologyImage(morph_wand,ThinningMorphology,2,&l_KI);
Etc. would be useful. Yes I know the above is completely wrong. Think of it as a kind of pseudo code. For what it's worth though if you do try to compile the above you get:
jpegtobw.c:116:40: warning: character constant too long for its type
jpegtobw.c: In function ‘ConvertJPEGtoBWArray’:
jpegtobw.c:116: warning: passing argument 2 of ‘AcquireKernelBuiltIn’ makes pointer from integer without a cast
/usr/include/ImageMagick/magick/morphology.h:126: note: expected ‘const struct GeometryInfo *’ but argument is of type ‘int’
jpegtobw.c:116: error: invalid initializer
Are there any pointers? Searching the web for these functions simply gives the C and Header documentation found here and on mirrors. Thanks in advance.
**EDIT**
I have something that compiles with this:
/* Apply Morphology */
MorphologyMethod l_MM=ThinningMorphology;
KernelInfoType l_KIT=FreiChenKernel;
struct _GeometryInfo l_GI;
l_GI.rho=0; l_GI.sigma=0; l_GI.xi=0; l_GI.psi=0; l_GI.chi=0;
struct KernelInfo *l_KI;
l_KI=AcquireKernelBuiltIn(l_KIT,&l_GI);
MagickMorphologyImage(morph_wand,l_MM,2,l_KI);
but it does nothing appreciable. Any pointers? Other wand functions like Quantize and the Sigma Threshold Pixel iterator example in the docs are working aok.
Diziet