Image convolution: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Restore removed Imagemagick convolution entry. It works but need to install from github not CPAN) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 278:
} else { fprintf(stderr, "err reading %s\n", input); }
}</lang>
=={{header|Common Lisp}}==
Uses the RGB pixel buffer package defined here [[Basic bitmap storage#Common Lisp]]. Also the PPM file IO functions defined in
Line 1,213 ⟶ 1,214:
mask := Matrix([[1,2,3],[4,5,6],[7,8,9]]);
pic := ImageTools:-Convolution(pic, mask);</lang>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
Line 1,577:
Compare offsite images: [https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/frog.png frog.png] vs.
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/frog_convolution.png frog_convolution.png]
=={{header|Perl 6}}==▼
===Perl 5 PDL library===▼
<lang perl6>use PDL:from<Perl5>;▼
use PDL::Image2D:from<Perl5>;▼
my $kernel = pdl [[-2, -1, 0],[-1, 1, 1], [0, 1, 2]]; # emboss▼
my $image = rpic 'frog.png';▼
my $smoothed = conv2d $image, $kernel, {Boundary => 'Truncate'};▼
wpic $smoothed, 'frog_convolution.png';</lang>▼
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]▼
===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}}==
Line 1,871 ⟶ 1,824:
(flomap->bitmap (flomap-convolve flmp (flvector -1. -1. -1. -1. 4. -1. -1. -1. -1.)))
"out/convolve-etch-3x3.png"))</lang>
(formerly Perl 6)
▲===Perl 5 PDL library===
▲<lang perl6>use PDL:from<Perl5>;
▲use PDL::Image2D:from<Perl5>;
▲my $kernel = pdl [[-2, -1, 0],[-1, 1, 1], [0, 1, 2]]; # emboss
▲my $image = rpic 'frog.png';
▲my $smoothed = conv2d $image, $kernel, {Boundary => 'Truncate'};
▲wpic $smoothed, 'frog_convolution.png';</lang>
▲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]
▲===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|Ruby}}==
|