Image convolution: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) (→{{header|Perl 6}}: clone of Perl 5, for now) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Restore removed Imagemagick convolution entry. It works but need to install from github not CPAN) |
||
Line 1,579: | Line 1,579: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
===Perl 5 PDL library=== |
|||
<lang perl6>use PDL:from<Perl5>; |
<lang perl6>use PDL:from<Perl5>; |
||
use PDL::Image2D:from<Perl5>; |
use PDL::Image2D:from<Perl5>; |
||
Line 1,589: | Line 1,591: | ||
Compare offsite images: [https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/frog.png frog.png] vs. |
Compare offsite images: [https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/frog.png frog.png] vs. |
||
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/frog_convolution.png frog_convolution.png] |
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/frog_convolution.png frog_convolution.png] |
||
===Imagemagick library=== |
|||
<lang perl6> |
|||
# Note: must install version from github NOT version from CPAN which needs to be updated. |
|||
# Reference: |
|||
# https://github.com/azawawi/perl6-magickwand |
|||
# http://www.imagemagick.org/Usage/convolve/ |
|||
use v6; |
|||
use MagickWand; |
|||
# A new magic wand |
|||
my $original = MagickWand.new; |
|||
# Read an image |
|||
$original.read("./Lenna100.jpg") or die; |
|||
my $o = $original.clone; |
|||
# using coefficients from kernel "Sobel" |
|||
# http://www.imagemagick.org/Usage/convolve/#sobel |
|||
$o.convolve( [ 1, 0, -1, |
|||
2, 0, -2, |
|||
1, 0, -1] ); |
|||
$o.write("Lenna100-convoluted.jpg") or die; |
|||
# And cleanup on exit |
|||
LEAVE { |
|||
$original.cleanup if $original.defined; |
|||
$o.cleanup if $o.defined; |
|||
}</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |