Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have written a script to open and process all the pixels of a *.jpg file. My problem is that I need a way to convert the different RGB values to colors, such as redish, blueish, greenish ect. After doing this i would also like perl to color a box with the color it said the pixel was. Any ideas/help/suggestions would be appreciated. Here is my code so far:
use GD; open IMA,"many.jpg" or die "NO file, $!"; binmode IMA; $image=new GD::Image->newFromJpeg(IMA); ($x,$y)=$image->getBounds(); for $ix (0..$x-1) { for $iy (0..$y-1) { ($r,$g,$b)=$image->rgb($im->getPixel($ix,$iy)); if($r ne $or) { printf "%2x%2x%2x\n",$r,$g,$b; print "$r, $g, $b\n"; #print "$image\n"; } $or = $r; } } close IMA;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Convert RGB to an actual color
by Zaxo (Archbishop) on Nov 20, 2002 at 05:12 UTC | |
Re: Convert RGB to an actual color
by hawtin (Prior) on Nov 19, 2002 at 23:37 UTC | |
•Re: Convert RGB to an actual color
by merlyn (Sage) on Nov 20, 2002 at 00:14 UTC | |
Re: Convert RGB to an actual color
by pg (Canon) on Nov 20, 2002 at 02:07 UTC | |
Re: Convert RGB to an actual color
by Anonymous Monk on Nov 20, 2002 at 15:55 UTC | |
Re: Convert RGB to an actual color
by Anonymous Monk on Nov 21, 2002 at 23:41 UTC |
Back to
Seekers of Perl Wisdom