Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
画像Hacks
画像Hacks
画像Hacks
画像Hacks
use strict;
use warnings;
use Imager;

my $file = 'doya.jpg';
my $image = Imager->new( file => $file ) or die Imager->errstr;
$image = $image->scale( xpixels => 100 );
$image->write( file => 'out.jpg' ) or die $image->errstr;
...;
my $image = Imager->new( file => $file ) or die Imager->errstr;
$image = $image->scale( xpixels => 100 );
$image = $image->crop( height => 100 ); #
$image->write( file => 'out.jpg' ) or die $image->errstr;
...;
画像Hacks
画像Hacks
画像Hacks
画像Hacks
sub get_map {
    my $gamma = shift;
    my @map =
          map { int( 0.5 + 255 * ( $_ / 255 )**$gamma ) } 0 .. 255;
    return @map;
}

$image->map(
    red   => get_map(0.5),
    green => get_map(0.65),
    blue => get_map(0.8)
);




my $waku = Imager->new( file => 'waku.png' );
$image->rubthrough( src => $waku );
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
...;
my $font = Imager::Font->new( file => 'HiraKakuPro-W3.ttf' );
...;
...;
       my $qrcode = Imager::QRCode->new(
           size          => 3,
           margin        => 0,
           version       => 1,
           level         => 'M',
           casesensitive => 1,
           lightcolor    => Imager::Color->new( 255, 255, 255 ),
           darkcolor     => Imager::Color->new( 35, 54, 92 ),
       );
       my $qr = $qrcode->plot( $text );
       $qr = $qr->scale( xpixels => 90 );
       $image = $image->paste( left => 590, top => 198, src => $qr );

...;
画像Hacks
画像Hacks
画像Hacks
ff
...;
       my $diff = $org->difference( other => $numbers[$n] );
       $diff = $diff->to_rgb8;
       my $count;
       for ( my $x = 0 ; $x < $width ; $x++ ) {
           for ( my $y = 0 ; $y < 38 ; $y++ ) {
               my $pixel = $diff->getpixel( x => $x, y => $y );
               next unless $pixel;
               my $result = $pixel->rgba;
               $count++ if $result == 255;
           }
       }
...;
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
use Imager;
use Image::ObjectDetect;

my   $image      =   Imager->new->read( file => 'picture.jpg' );
my   $cascade    =   './haarcascade_frontalface_alt2.xml';
my   $detector   =   Image::ObjectDetect->new($cascade);
my   @faces      =   $detector->detect($file); #←
my $purple_source = Imager->new->read(file => './purple.png');
my $aspect = 1.5;
for my $face (@faces) {
    my $purple = $purple_source->scale(
        xpixels => $face->{width} / $aspect,
        ypixels => $face->{height} / $aspect,
    );
    $image->rubthrough(
        tx => $face->{width} / $aspect / 2 + $face->{x},
        ty => $face->{height} / $aspect + $face->{y},
        src => $purple,
    );
}
$image->write( file => './output.jpg' );
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
•
    –
    –
•
    –
    –
•
•
    –
        •
    –
        •
•
    –
        •
        •
        •
use Acme::Porn::JP;

…;

my $porn = Acme::Porn::JP->new;
my $actress_list = $porn->actress();
for my $actress ( @$actress_list ){
    search("$query $actress”);
}

…;

$ perl -MAcme::Porn::JP -e '$p = Ace::Porn::JP->new; print
scalar @{$p->actress};’
4502
画像Hacks
•
•
    –
    –
•
•
    –
•
        positive.dat
        [filename]	
  [#	
  of	
  objects]	
  [[x	
  y	
  width	
  height]	
  [...	
  2nd	
  object]	
  ...]
        images/01.jpg	
  1	
  140	
  100	
  45	
  45

        nega%ve.dat
        images/neg-­‐01.jpg
        images/neg-­‐02.jpg
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks
画像Hacks

More Related Content

画像Hacks

  • 5. use strict; use warnings; use Imager; my $file = 'doya.jpg'; my $image = Imager->new( file => $file ) or die Imager->errstr; $image = $image->scale( xpixels => 100 ); $image->write( file => 'out.jpg' ) or die $image->errstr;
  • 6. ...; my $image = Imager->new( file => $file ) or die Imager->errstr; $image = $image->scale( xpixels => 100 ); $image = $image->crop( height => 100 ); # $image->write( file => 'out.jpg' ) or die $image->errstr; ...;
  • 11. sub get_map { my $gamma = shift; my @map = map { int( 0.5 + 255 * ( $_ / 255 )**$gamma ) } 0 .. 255; return @map; } $image->map( red => get_map(0.5), green => get_map(0.65), blue => get_map(0.8) ); my $waku = Imager->new( file => 'waku.png' ); $image->rubthrough( src => $waku );
  • 20. ...; my $font = Imager::Font->new( file => 'HiraKakuPro-W3.ttf' ); ...;
  • 21. ...; my $qrcode = Imager::QRCode->new( size => 3, margin => 0, version => 1, level => 'M', casesensitive => 1, lightcolor => Imager::Color->new( 255, 255, 255 ), darkcolor => Imager::Color->new( 35, 54, 92 ), ); my $qr = $qrcode->plot( $text ); $qr = $qr->scale( xpixels => 90 ); $image = $image->paste( left => 590, top => 198, src => $qr ); ...;
  • 25.
  • 26. ...; my $diff = $org->difference( other => $numbers[$n] ); $diff = $diff->to_rgb8; my $count; for ( my $x = 0 ; $x < $width ; $x++ ) { for ( my $y = 0 ; $y < 38 ; $y++ ) { my $pixel = $diff->getpixel( x => $x, y => $y ); next unless $pixel; my $result = $pixel->rgba; $count++ if $result == 255; } } ...;
  • 32. use Imager; use Image::ObjectDetect; my $image = Imager->new->read( file => 'picture.jpg' ); my $cascade = './haarcascade_frontalface_alt2.xml'; my $detector = Image::ObjectDetect->new($cascade); my @faces = $detector->detect($file); #← my $purple_source = Imager->new->read(file => './purple.png'); my $aspect = 1.5; for my $face (@faces) { my $purple = $purple_source->scale( xpixels => $face->{width} / $aspect, ypixels => $face->{height} / $aspect, ); $image->rubthrough( tx => $face->{width} / $aspect / 2 + $face->{x}, ty => $face->{height} / $aspect + $face->{y}, src => $purple, ); } $image->write( file => './output.jpg' );
  • 40. – – • – –
  • 41. • • – • – • • – • • •
  • 42. use Acme::Porn::JP; …; my $porn = Acme::Porn::JP->new; my $actress_list = $porn->actress(); for my $actress ( @$actress_list ){ search("$query $actress”); } …; $ perl -MAcme::Porn::JP -e '$p = Ace::Porn::JP->new; print scalar @{$p->actress};’ 4502
  • 44. • • – – • • – • positive.dat [filename]  [#  of  objects]  [[x  y  width  height]  [...  2nd  object]  ...] images/01.jpg  1  140  100  45  45 nega%ve.dat images/neg-­‐01.jpg images/neg-­‐02.jpg