Permalink
Browse files

Added hue_frequencies example

git-svn-id: svn://localhost:81/cpan/perl5-imager-skindetector@116 d5a6ac26-b448-f74c-955c-92d14582c9b2
  • Loading branch information...
1 parent c3d2cda commit e4bed58efcaa3af7c1bee8b21061d7fe3c2e7f03 @cosimo committed Oct 11, 2008
Showing with 59 additions and 28 deletions.
  1. +13 −11 MANIFEST
  2. +17 −17 Makefile.PL
  3. +29 −0 examples/hue_frequencies.pl
View
@@ -1,11 +1,13 @@
-Changes
-MANIFEST
-Makefile.PL
-README
-lib/Imager/SkinDetector.pm
-examples/is_skinny.pl
-examples/ferrari.bmp
-examples/ferrari.png
-examples/model.bmp
-examples/model.png
-t/00-load.t
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/Imager/SkinDetector.pm
+examples/hue_frequencies.pl
+examples/is_skinny.pl
+examples/ferrari.bmp
+examples/ferrari.png
+examples/model.bmp
+examples/model.png
+t/00-load.t
+META.yml Module meta-data (added by MakeMaker)
View
@@ -1,17 +1,17 @@
-use strict;
-use warnings;
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Imager::SkinDetector',
- AUTHOR => 'Cosimo Streppone <cosimo@cpan.org>',
- VERSION_FROM => 'lib/Imager/SkinDetector.pm',
- ABSTRACT_FROM => 'lib/Imager/SkinDetector.pm',
- PL_FILES => {},
- PREREQ_PM => {
- 'Test::More' => 0,
- 'Imager' => 0, # Check version
- },
- dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- clean => { FILES => 'Imager-SkinDetector-*' },
-);
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Imager::SkinDetector',
+ AUTHOR => 'Cosimo Streppone <cosimo@cpan.org>',
+ VERSION_FROM => 'lib/Imager/SkinDetector.pm',
+ ABSTRACT_FROM => 'lib/Imager/SkinDetector.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'Imager' => 0, # Check version
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'Imager-SkinDetector-*' },
+);
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+#
+# Outputs some *simple* color histogram values
+# based on hue of colors found in the picture
+#
+# Usage:
+# perl hue_frequencies.pl <some_png_picture>
+#
+# Example:
+# perl hue_frequencies.pl ferrari.png
+#
+# $Id: $
+
+use strict;
+use Imager::SkinDetector;
+
+my $name = $ARGV[0]
+ or die "Usage: $0 <picture_filename>\n";
+
+my $img = Imager::SkinDetector->new(file => $name)
+ or die "Can't load image '$name'.\n";
+
+my @freq = $img->hue_frequencies();
+
+my $n = 0;
+for (@freq) {
+ printf "Interval n. %d\tValue: %.3f%%\n", ++$n, 100*$_;
+}
+

0 comments on commit e4bed58

Please sign in to comment.