Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Image-convolution/Raku/image-convolution-1.raku
Normal file
8
Task/Image-convolution/Raku/image-convolution-1.raku
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
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';
|
||||
30
Task/Image-convolution/Raku/image-convolution-2.raku
Normal file
30
Task/Image-convolution/Raku/image-convolution-2.raku
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue