On 11/3/06, Brian Jackson <[EMAIL PROTECTED]> wrote:

But when the windos and mac ports happen, then I have to convert my
shell script to whatever in the hell windos uses for shell scripts.
Mac, not a problem, it's got bash.  Another reason I want a 100% perl
solution.

Here's some 100% perl code to do pretty much what you want:

        my $temp;
        $temp = $image->Clone();
        $temp->Modulate("100, 0, 0") unless $bw;
        my @black = Histogram($temp);
        $temp = $image->Clone();
        $temp->Channel("Red");
        my @red = Histogram($temp);
        $temp = $image->Clone();
        $temp->Channel("Green");
        my @green = Histogram($temp);
        $temp = $image->Clone();
        $temp->Channel("Blue");
        my @blue = Histogram($temp, $blackpoint, $whitepoint);

sub Histogram
{
        my ($image) = @_;

        my $filename = "histogram" . rand;
        $image->Write("histogram:$filename");
        undef $image->[0];
        my $hg = new Image::Magick;
        $hg->Read($filename);
        unlink $filename;
        return $hg
}

Maybe I just need to learn some graphics programming and understand that
HUGE array that is returned from the Histogram() method  :-D

Is the Historgram() method much faster than what you have now?

> To use less time, you may want to use a Q8 build because it will only
> have half the data to process. Also, you should try computing a
> single color histogram and using the individual channels from it to
> make the different color histograms.

And actually, computing the histogram first and then trying to extract
the channels from that...doesn't seem to work for me.  I get 3 black
files :(

What do you mean by black? Do you mean every pixel is black? Or just
that there are no colored pixels?

> A third trick would be to resize the image, then compute the
> historgrams from that. This is a notable idea because that's how
> Photoshop (and presumably The GIMP) can do it so much faster than
> ImageMagick.

This is from a reduced image size.  That's how my program can process
100's of photos in a few minutes.

Do you resize or resample? The method you use will make a difference.

GNS
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to