Now, I want to add curvature to the edge of the image to give the viewer the impression that she is looking at the round edge of the planet. Imagine that the stretched and sharpened image from the previous page is made up of scan lines that are stacked one on top of the other. Now imagine that each scan line can be moved from side to side independently of the scan lines above and below it. Think of the image as a contour guage.

contour guage

If I push the right side of my contour-guage image against the inside of a circle, I will get the effect I am looking for. I determine a radius for that circle from the number of scan lines in the image and the number of degrees of latitude encompassed by those scan lines. You can read the starting and ending latitude from the HDF file. I use NCSA's modification of the NetCDF ncdump program and the unix grep command.

ncdump -h S1999244172740.L1A_HNSG | grep "Center Latitude"

This produces the following output.

                :Scene Center Latitude = 41.203136f ;
                :Start Center Latitude = 64.144318f ;
                :End Center Latitude = 17.770613f ;

The number of scan lines is also the height of the image produced by swl1a2tc. One way to get this information is with the Netpbm command, pnmfile.

pnmfile S1999244172740.L1A_HNSG.left_edge_stretched.sharpened.ppm

This produces the following output.

S1999244172740.L1A_HNSG.left_edge_stretched.sharpened.ppm:        PPM raw, 1798 by 4685  maxval 255

That is, the image is 1798 pixels wide and 4685 lines high. I can now compute the radius as follows.

radius = (img_height/2)/sin(degrees_of_latitude/2)
       = (   4685   /2)/sin(   ( 64 - 18 )     /2)
       = 5995

One other thing that I need to determine is where along the right edge of the image I want the rightmost part of the curve to fall. As with most things, there is more than one way to do this. I view the image with xv and, with my middle mouse button, subjectively determine that I want the curve to crest at line number 4000 (almost nine tenths of the way down the image).

Now that I have some numbers to work with I will use a mixture of Perl, ImageMagick, and Netpbm to push the right side of my contour-guage image against the inside of a circle.

Draw a portion of the right half of a circle having a radius of 5995 pixels and cut out the rightmost portion of that drawing so that the dimensions match those of the image to be sheared (S1999244172740.L1A_HNSG.left_edge_stretched.sharpened.ppm).

perl -e 'print "P6\n5995 4685\n255\n",(chr(0)x(5995*4685*3))' | \
convert -pen rgb:ff/ff/ff -draw 'circle 0,4000 5994,4000' - - | \
pnmcut 4197 0 1798 4685 | pnmdepth 255 > mask.pgm

scaled-down version of the circle image produced by the above command sequence

Measure how many pixels each scan line of the true-color image will have to be slid over to make it conform to the above circle fragment. Save the measurements in a text file.

perl -e '<>;<>;<>;while(read(STDIN,$d,1798)){ \
$d=~s/\xff//g;$l=length $d;print "$l\n";}' \
< mask.pgm > measurements.txt

Use these measurements to shear the true-color image.

perl -e '$h1=<>;<>;$h2=<>;$h3=<>; \
open F,"measurements.txt" or die; \
$b=chr(0); \
print "$h1$h2$h3"; \
while(read(STDIN,$d,3*1798)){ \
chop($n=<F>); \
$l=3*(1798-$n); \
$d=substr($d,3*$n,$l).$b x (3*$n); \
print $d;}' \
< S1999244172740.L1A_HNSG.left_edge_stretched.sharpened.ppm \
> S1999244172740.L1A_HNSG.sheared.ppm

true-color image sheared to a rounded edge

At this point the effect is mostly complete. What remain are a few artistic touches such as adding some sky at the horizon and giving the storm a hint of three-dimensionality.

Previous Next


Norman Kuring <norman@seawifs.gsfc.nasa.gov>

16 November 2000