| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | pp_add_exported('', 'delta_e_2000'); | ||||||||||
| 4 | |||||||||||
| 5 | $PDL::Graphics::ColorDistance::VERSION = '0.0.1'; | ||||||||||
| 6 | |||||||||||
| 7 | pp_setversion("'$PDL::Graphics::ColorDistance::VERSION'"); | ||||||||||
| 8 | |||||||||||
| 9 | pp_addpm({At=>'Top'}, <<'EOD'); | ||||||||||
| 10 | |||||||||||
| 11 | =encoding utf-8 | ||||||||||
| 12 | |||||||||||
| 13 | =head1 NAME | ||||||||||
| 14 | |||||||||||
| 15 | PDL::Graphics::ColorDistance | ||||||||||
| 16 | |||||||||||
| 17 | =head1 VERSION | ||||||||||
| 18 | |||||||||||
| 19 | 0.0.1 | ||||||||||
| 20 | |||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||
| 22 | |||||||||||
| 23 | This is a PDL implementation of the CIEDE2000 color difference formula. | ||||||||||
| 24 | |||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||
| 26 | |||||||||||
| 27 | use PDL::LiteF; | ||||||||||
| 28 | use PDL::Graphics::ColorDistance; | ||||||||||
| 29 | |||||||||||
| 30 | my $lab1 = pdl([ 50, 2.6772, -79.7751 ]); | ||||||||||
| 31 | my $lab2 = pdl([ 50, 0, -82.7485 ]); | ||||||||||
| 32 | my $delta_e = delta_e_2000($lab1, $lab2); | ||||||||||
| 33 | |||||||||||
| 34 | # $delta_e == 2.0425; | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | 1 | ▶ | |||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | use warnings; | ||||||||||
| 40 | 1 | ▶ | |||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | use PDL::LiteF; | ||||||||||
| 43 | 0 | ▶ | |||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | $PDL::onlinedoc->scan(__FILE__) if $PDL::onlinedoc; | ||||||||||
| 45 | |||||||||||
| 46 | EOD | ||||||||||
| 47 | |||||||||||
| 48 | pp_addhdr(' | ||||||||||
| 49 | #include <math.h> | ||||||||||
| 50 | #include "color_distance.h" /* Local decs */ | ||||||||||
| 51 | ' | ||||||||||
| 52 | ); | ||||||||||
| 53 | |||||||||||
| 54 | pp_def('delta_e_2000', | ||||||||||
| 55 | Pars => 'double lab1(c=3); double lab2(c=3); double [o]delta_e()', | ||||||||||
| 56 | Code => ' | ||||||||||
| 57 | deltaE2000( $P(lab1), $P(lab2), $P(delta_e) ); | ||||||||||
| 58 | ', | ||||||||||
| 59 | |||||||||||
| 60 | HandleBad => 1, | ||||||||||
| 61 | BadCode => ' | ||||||||||
| 62 | /* First check for bad values */ | ||||||||||
| 63 | if ($ISBAD(lab1(c=>0)) || $ISBAD(lab1(c=>1)) || $ISBAD(lab1(c=>2)) || | ||||||||||
| 64 | $ISBAD(lab2(c=>0)) || $ISBAD(lab2(c=>1)) || $ISBAD(lab2(c=>2))) { | ||||||||||
| 65 | loop (c) %{ | ||||||||||
| 66 | $SETBAD(lab1()); | ||||||||||
| 67 | $SETBAD(lab2()); | ||||||||||
| 68 | %} | ||||||||||
| 69 | /* skip to the next triple */ | ||||||||||
| 70 | } | ||||||||||
| 71 | else { | ||||||||||
| 72 | deltaE2000( $P(lab1), $P(lab2), $P(delta_e) ); | ||||||||||
| 73 | } | ||||||||||
| 74 | ', | ||||||||||
| 75 | |||||||||||
| 76 | Doc => <<'DOCUMENTATION', | ||||||||||
| 77 | |||||||||||
| 78 | =for ref | ||||||||||
| 79 | |||||||||||
| 80 | Calculates the ΔE*00 (delta e, color distance) between two Lab colors | ||||||||||
| 81 | |||||||||||
| 82 | =for usage | ||||||||||
| 83 | |||||||||||
| 84 | Usage: | ||||||||||
| 85 | |||||||||||
| 86 | my $delta_e = delta_e_2000($lab1, $lab2); | ||||||||||
| 87 | |||||||||||
| 88 | DOCUMENTATION | ||||||||||
| 89 | BadDoc => <<BADDOC, | ||||||||||
| 90 | |||||||||||
| 91 | If C<delta_e_2000> encounters a bad value in any of the L, a, or b values the input values will be marked as bad | ||||||||||
| 92 | |||||||||||
| 93 | BADDOC | ||||||||||
| 94 | ); | ||||||||||
| 95 | |||||||||||
| 96 | |||||||||||
| 97 | pp_addpm(<<'EOD'); | ||||||||||
| 98 | |||||||||||
| 99 | =head1 DEVELOPMENT | ||||||||||
| 100 | |||||||||||
| 101 | This module is being developed via a git repository publicly available at http://github.com/ewaters/perl-PDL-Graphics-ColorDistance. | ||||||||||
| 102 | |||||||||||
| 103 | =head1 COPYRIGHT | ||||||||||
| 104 | |||||||||||
| 105 | Copyright (c) 2013 Eric Waters and Shutterstock Images (http://shutterstock.com). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 106 | |||||||||||
| 107 | The full text of the license can be found in the LICENSE file included with this module. | ||||||||||
| 108 | |||||||||||
| 109 | =head1 AUTHOR | ||||||||||
| 110 | |||||||||||
| 111 | Eric Waters <ewaters@gmail.com> | ||||||||||
| 112 | |||||||||||
| 113 | =cut | ||||||||||
| 114 | |||||||||||
| 115 | EOD | ||||||||||
| 116 | |||||||||||
| 117 | pp_done(); | ||||||||||