Image-DominantColors

 view release on metacpan or  search on metacpan

lib/Image/ColorCollection.pm  view on Meta::CPAN

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#store the centroid here..
#store belongstome
sub getCentroid {
        my $class = shift;
        return $class->{centroid};
}
sub addColor {
        my ($class, $c) = @_;
        push @{$class->{colors}}, $c;
}
sub updateCentroid {
                my ($class, $c) = @_;
                my $shift = 0;
                my @colors = @{$class->{colors}};
                if(scalar(@colors) == 0)
                {
                        return 0;
                }
                my $rAvg = int(sum(map {$_->{r}} @colors)/@colors);
                $shift += $class->{centroid}->{r} - $rAvg;
                



( run in 1.130 second using v1.01-cache-2.11-cpan-49f99fa48dc )