Color::Model::Munsell::Util - Utility subroutines for Color::Model::Munsell
use Color::Model::Munsell; use Color::Model::Munsell::Util qw(hvc2RGB); use Color::Model::RGB; my $m = Color::Model::Munsell->new("5R 4.5/14"); printf("Munsell: %s = RGB: #%s\n", $m, hvc2RGB($m));
Color::Model::Munsell::Util gives some utility subroutines for color conversion from Munsell to CIE xyY, XYZ or RGB.
Color::Model::Munsell::Util
Only subroutine Munsell2RGB is exported by defalut.
$n = huedegree( "5R" );
Return degree number of Hue; considered 10.0RP is 0, 10R to be 10, 10YR 20, ..., and ends 9.9RP as 99.9. If bad formatted hue given, this returns undef.
Munsell2xyY() returns an array of CIE x, y and Y which are calculated with linear interpolation from Munsell-xyY table.
use Color::Model::Munsell::Util qw(Munsell2xyY); $m = Color::Model::Munsell->new("2.5G 5.5/10"); ($x, $y, $Y) = Munsell2xyY($m);
This Munsell-xyY table is from MCSL, R.I.T. which condition is using illuminant C and the CIE 1931 2 degree observer.
Munsell2XYZ( $m ) Munsell2XYZD65( $m [, "ChromaticAdaptType" ] )
Munsell2XYZ() and Munsell2XYZD65() returns an array of CIE X,Y and Z.
$m = Color::Model::Munsell->new("7.5B 6/10"); printf("%s -> CIE XYZ (%.f, %.f, %.f)", $m, Munsell2XYZ($m)); # perform cromatic adaptation from C to D65 printf("%s -> CIE XYZ (%.f, %.f, %.f) via Chromatic Adaptation", $m, Munsell2XYZD65($m));
Munsell2XYZ() simply calculates XYZ from xyY. And Munsell2XYZD65() calculates them with chromatic adaptatation to illuminant D65. Adaptation type shuld be "XYZ", "vonKries", "Bradford" or "None". If Omitted, "Bradford" is used. Specifying "None" is same as calling Munsell2XYZ().
Munsell2rgb( $m [, "RGBModel" [, "ChromaticAdaptType" ]] ) Munsell2RGB( $m [, "RGBModel" [, "ChromaticAdaptType" [, $gamma ]]] )
Munsell2rgb() returns an array of r, g and b values which calculated from XYZ with transformation matrix. And Munsell2RGB() returns Color::Model::RGB object.
Color::Model::RGB
$m = Color::Model::Munsell->new("7PB 2.5/3"); printf("%s -> RGB %s of sRGB", $m, Munsell2RGB($m)); printf("%s -> RGB %s of AdobeRGB(1998)", $m, Munsell2RGB($m,"AdobeRGB"), 2.2);
RGBModel should be "sRGB", "AdobeRGB" that means Adobe RGB(1998), "AppleRGB" or "NTSC". A gamma value will be used when RGB model is not sRGB.
calc_Yc( $m )
calc_Yc() calculates Y value of illuminant C and 2 degree observer from Munsell value. Argument must be a Color::Model::Munsell object or Munsell value.
$m = Color::Model::Munsell->new("5R 4/14") printf "%.4f", calc_Yc( $m ); printf "%.4f", calc_Yc( 7.5 );
Takahiro Onodera, <ong at garakuta.net>
<ong at garakuta.net>
Please report any bugs or feature requests to bug-color-model-munsell-util at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Color-Model-Munsell-Util. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-color-model-munsell-util at rt.cpan.org
Color::Model::Munsell Color::Model::RGB
Munsell Color Science Laboratory, R.I.T http://www.cis.rit.edu/mcsl - Munsell-xyY data comes from this.
BruceLindbloom.com http://www.brucelindbloom.com/ - Transformation matrixes and important knowledge are from this site.
Japanese Industrial Standards(JIS) JIS Z 8721(1993)
Copyright 2010 T.Onodera.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
To install Color::Model::Munsell::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Color::Model::Munsell::Util
CPAN shell
perl -MCPAN -e shell install Color::Model::Munsell::Util
For more information on module installation, please visit the detailed CPAN module installation guide.