Lo all,
I know this should be simple, but I can't seem to find an easy solution.
I use pngs to store actual data. They are 8 bit indexed images. An indexed
palette is applied to give them life, but the data is in the image stored as
0-255
For instance, I have a picture of florida and the gulf of mexico with a logo
and such. The data values 0 - 255 all mean something to me. (Water
temperature or chlorophyll level) I can color them anyway I want depending on
need whether it is winter or summer for instance. I take the value and run it
though a calculation to come up with the real temperature value for instance.
We use IDL alot for this type of work but I want to see what image magick can
do.
I am trying to see what I can do with image magick. I want to do some simple
stuff like come up with hotspots. I need to take a climatology in the form of
an averaged png and then look at it against today's image. Thus I need to go
a difference bewteen the image and see how much from normal they are. I am
olnly looking at heating events right now (not cooling events so a neagtive
number would be discarded at this time)
So lets say I have an image with these values in the array:
100 102 101 101 102
100 100 101 101 100
100 100 101 101 103
100 103 101 105 102
100 102 101 101 102
100 100 108 101 102
And the climatology here:
101 103 101 101 102
101 101 101 101 100
102 102 101 101 103
100 103 101 104 102
100 102 101 101 102
100 100 108 101 102
I want to be able to get this (I don't know what to do for neagtive numbers
except to discard them at this point):
1 1 0 0 0
1 1 0 0 0
2 2 0 0 0
0 3 0 2 0
0 0 0 0 0
0 0 0 0 0
I also want to keep the current "indexed palette", or not, and apply it to the
array I come up with. Further, I have a "filter" so to speak. A coastline
file that I want to drop over the image such that if the values in the array
are less than a certain number, they are kept, but if they are over 250, lets
say (I use index values of 250 and up as coastline, land, logo, etc) and
apply colors to them.
For me, the original values in the image are the most important, not the RBG
colors that are associated with them.
I have tried a bunch of things but am coming up short. I also keep getting a
new index pallete for instance. :
cat image_test.pl
#!/usr/local/bin/perl
use Image::Magick;
my($image_a,$image_b,$image_c, $x, $y);
$image_a = "all.232_to_238_day_night.florida.png";
$image_b = "MODIS.2008238.184900.florida.seadas_sst.png";
$image_c = "florida_sst_cc_cl_new.png"; #mask
$image_reference = Image::Magick->new;
$image_subject = Image::Magick->new;
$image_mask = Image::Magick->new;
$x = $image_reference->Read($image_a);
warn "$x" if "$x";
($a, $b, $c, $d) = $image_reference->Get('colormap', 'magick', 'class',
'index');
print qq(\$a=$a, \$b=$b \$c=$c \$d=$d\n);
$y = $image_subject->Read($image_b);
warn "$y" if "$y";
$z = $image_mask->Read($image_c);
warn "$z" if "$z";
$image_reference->Composite(image=>$image_subject,compose=>'Difference');
$image_reference->Quantize(global_colormap=>'True');
$image_reference->Write(filename=>"png:output.png", compression=>'Zip',);
undef $image_reference;
undef $image_subject;
exit;
I know the above is mostly crap. Thus, any help understanding how to work with
the "Values" 0-255, masks to drop onto an image, and apply palettes, etc
would be greatly appreciated. I need to ignore the RGB, and apply palettes at
the end, or keep the existing palette. I saw the routines to pick out single
values at point x,y, and use that elsewhere. But I was hoping to be a little
mre global and quick rather than looping though an object and writing it out
again. (Not that I have figured out how to do that yet either. I do use image
magick to pull single points and use that point in a calculation, but I would
also like to use it to pull a 3x3 box lets say and then do a mean on it, but
that's another day)
Thanks so much in advance for any help.
Brock
--
Brock Murch
Institute for Marine Remote Sensing/IMaRS
College of Marine Science
University of South Florida
140 7th Ave. South
St Petersburg, FL 33701
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users