Drkcore

10 09 2008 perl Tweet

Imagerでlomo風に

lomo風にしてみたくなった。

sample

NK705で撮ったサンプルをlomo風味に。

sample_lomo

コード

use Imager;

my $source = shift;
my $lsat = 0.0;
my $usat = 0.2;
my $contrast = 1.5;
my $scale = 1.5;

my $img = Imager->new();

$img->read(file => $source);

my ($halfwidth, $halfheight)  = ($img->getwidth/2, $img->getheight/2);
my ($endx, $endy);

if($img->getwidth > $img->getheight){
  $endx = $img->getwidth;
  $endy = $halfheight;
}
else {
  $endx = $halfwidth;
  $endy = $img->getheight;
}

# contrast & sat
$img->filter(type=>"contrast", intensity=>$contrast);
$img->filter(type=>"autolevels", lsat=>$lsat, usat=>$usat);

# fountain
my $overexpo = $img->copy;
$overexpo->filter(type     => "fountain",
        ftype    => 'radial',
        channels => 2,
        xa       => $halfwidth,
        ya       => $halfheight,
        xb       => $endx,
        yb       => $endy);

my $vignette = $overexpo->scale(
                scalefactor=>$scale
                   )->crop(
                       left=>($scale-1)*$halfwidth,
                       top=>($scale-1)*$halfheight,
                       width=>$img->getwidth,
                       height=>$img->getheight
                      );

$img->compose(src=>$nradial,tx=>0,ty=>0,opacity=>0.6,combine=>"mult");
$img->compose(src=>$overexpo,tx=>0,ty=>0,opacity=>0.4,combine=>"subtract");


$img->write(file => "lomonized.png");

こんな感じのレイヤーを重ねたイメージ。

sample_lomo

GIMP Lomo Pluginのソースを見ながらつくったのだけど、Imagerのアルファチャンネルの使い方がよくわからなかったのでちょっとさぼってる。そのせいで白のあたりが飛んでしまうのが気に入らない。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021