Page 1 of 1

help with coding Mogrify

Posted: 2014-09-02T10:30:41-07:00
by rleir
Here is the command line, which works fine:
$ convert 1345.jpg -colorspace gray \( +clone -blur 0x20 \) -compose Divide_Src -composite 1345photocopy1.jpg

# ref http://www.imagemagick.org/Usage/compose/#divide

I am having trouble coding some PerlMagick to do the same. What I have so far is shakey:

Code: Select all

 
    my $image = Image::Magick->new;
    my $x = $image->read( $sourceFile);
    if ("$x") { print LOGFILE "image read = $x   \n";   }

    $image->Quantize(colorspace=>'gray');
    my $q = $image->Clone();
    $q->Blur( radius=>16);
    $x = $image->Mogrify( 'Composite', compose=>'Divide_Src', composite=>'t' );
    if ("$x") {	print LOGFILE "image modu = $x   \n";   }
This throws an error:

Code: Select all

 Exception 410: composite image required `Image::Magick' @ error/Magick.xs/XS_Image__Magick_Mogrify/8255

Re: help with coding Mogrify

Posted: 2014-09-03T06:10:12-07:00
by magick
Use $image->Composite(), Mogrify is not required. The Composite() method requires an image to composite, use this argument: image=>$q, for example.

Re: help with coding Mogrify

Posted: 2014-09-03T11:48:47-07:00
by rleir
Thanks for helping. Now we have this:

Code: Select all

    $image->Quantize(colorspace=>'gray');
    my $q = $image->Clone();
    $q->Blur( radius=>16);
    $x = $image->Composite ( compose=>'Divide_Src', image=>$q );
    if ("$x") {	print LOGFILE "image modu = $x   \n";   }
The resulting image is all white.

There is no mention of compose=>'Divide_Src' in the doco, and I do not see an operator like division:
http://www.imagemagick.org/script/perl- ... manipulate

Evaluate has a divide operator, but it does not seem to work with two images.

Re: help with coding Mogrify

Posted: 2014-09-03T12:01:03-07:00
by snibgo
The resulting image is all white.
If you divide anything by itself, the result is 1.0, which is white.

Re: help with coding Mogrify

Posted: 2014-09-04T06:02:35-07:00
by rleir
In the original post (above) you will see a convert command line, which works well for me. I would like to translate that to PerlMagick, but no luck yet!

Another post discusses my goals: viewtopic.php?f=22&t=26190
Thanks
Rick

Re: help with coding Mogrify

Posted: 2014-09-04T12:18:10-07:00
by rleir
Aha. The Blur parameters.

In the command line, the blur radius of 0x20 is not hexadecimal 20. What it really means is radius=0, sigma=20.

For the same effect, does the perlmagick need to do this?
$q->Blur( radius=>0.0, sigma=>20.0);

Now the results of the Perlmagick are the same as for the command line, and they are suitable for OCR.