-->

Previous | Table of Contents | Next

Page 403

Often conversion from ppm to pgm will yield an image with contrast too low for good printer output. The program maximizes contrast between the gray levels' output.

A ppm input of n colors is read, and a pgm of n gray levels is written. The gray levels take on the values 0...n-1, while maxval takes on n-1.

The mapping from color to stepped grayscale can be performed in order of input pixel intensity, or input pixel frequency (number of repetitions).

OPTIONS

-frequency Sort input colors by the number of times a color appears in the input, before mapping to evenly distributed gray levels of output.
-intensity Sort input colors by their grayscale intensity, before mapping to evenly distributed gray levels of output. This is the default.

BUGS

Helpful only for images with a very small number of colors. Perhaps should have been an option to ppmtopgm(1).

SEE ALSO


ppmtopgm(1), ppmhist(1), ppm(5)

AUTHOR

Copyright" 1993 by Dan Stromberg.

22 July 1992

ppmdither

ppmdither—Ordered dither for color images

SYNOPSIS


ppmdither [-dim dimension][-red shades][-green shades][-blue shades][ppmfile]

DESCRIPTION

ppmdither reads a portable pixmap as input, and applies dithering to it to reduce the number of colors used down to the specified number of shades for each primary. The default number of shades is red=5, green=9, blue=5, for a total of 225 colors. To convert the image to a binary RGB format suitable for color printers, use -red 2 -green 2 -blue 2. The maximum number of colors that can be used is 256 and can be computed as the product of the number of red, green, and blue shades.

OPTIONS

-dim dimension The size of the dithering matrix. Must be a power of 2.
-red shades The number of red shades to be used; minimum of 2.
-green shades The number of green shades to be used; minimum of 2.
-blue shades The number of blue shades to be used; minimum of 2.

SEE ALSO


pnmdepth(1), ppmquant(1), ppm(5)

AUTHOR

Copyright" 1991 by Christos Zoulas.

14 July 1991

Page 404

ppmflash

ppmflash—Brighten a picture up to complete white-out

SYNOPSIS


ppmflash flashfactor [ppmfile]

DESCRIPTION

ppmflash reads a portable pixmap as input and increases its brightness by the specified flashfactor up to a total white-out image. The flashfactor may be in the range from 0.0 (original picture's brightness) to 1.0 (full white-out, The Second After).

As pnmgamma does not do the brightness correction in the way I wanted it, I wrote this small program.

This program is similar to ppmbrighten, but not exactly the same.

SEE ALSO


ppm(5), ppmdim(1), pnmgamma(1), ppmbrighten(1)

AUTHOR

Copyright" 1993 by Frank Neumann.

16 November 1993

ppmforge

ppmforge—Fractal forgeries of clouds, planets, and starry skies

SYNOPSIS


ppmforge [-clouds][-night][-dimension dimen][-hour hour][-inclination|-tilt angle]

[-mesh size][-power factor][-glaciers level][-ice level][-saturation sat]

[-seed seed] [-stars fraction][-xsize|-width width][-ysize|-height height]

DESCRIPTION

ppmforge generates three kinds of "random fractal forgeries," the term coined by Richard F. Voss of the IBM Thomas
J. Watson Research Center for seemingly realistic pictures of natural objects generated by simple algorithms embodying randomness and fractal self-similarity. The techniques used by ppmforge are essentially those given by Voss, particularly the technique of spectral synthesis explained in more detail by Dietmar Saupe. (The "See Also" subsection provides more detailed information about these men's work.)

The program generates two varieties of pictures, planets and clouds, which are just different renderings of data generated in an identical manner, illustrating the unity of the fractal structure of these very different objects. A third type of picture, a starry sky, is synthesized directly from pseudorandom numbers.

The generation of planets or clouds begins with the preparation of an array of random data in the frequency domain. The size of this array, the mesh size, can be set with the -mesh option; the larger the mesh, the more realistic the pictures, but the calculation time and memory requirement increases as the square of the mesh size. The fractal dimension, which you can specify with the -dimension option, determines the roughness of the terrain on the planet or the scale of detail in the clouds. As the fractal dimension is increased, more high frequency components are added into the random mesh.

After the mesh is generated, an inverse two-dimensional Fourier transform is performed upon it. This converts the original random frequency domain data into spatial amplitudes. You scale the real components that result from the Fourier transform into numbers from 0 to 1 associated with each point on the mesh. You can further modify this number by applying a power law scale to it with the -power option. Unity scale leaves the numbers unmodified; a power scale of 0.5 takes the square root

Page 405

of the numbers in the mesh, while a power scale of 3 replaces the numbers in the mesh with their cubes. Power law scaling is best envisioned by thinking of the data as representing the elevation of terrain; powers less than one yield landscapes with vertical scarps that look like glacial-carved valleys; powers greater than one make fairy-castle spires (which require large mesh sizes and high resolution for best results).

After these calculations, you have an array of the specified size containing numbers that range from 0 to 1. The pixmaps are generated as follows:

Clouds A color map is created that ranges from pure blue to white by increasing admixture (desaturation) of blue with white. Numbers less than 0.5 are colored blue, and numbers between 0.5 and 1.0 are colored with corresponding levels of white, with 1.0 being pure white.
Planet The mesh is projected onto a sphere. Values less than 0.5 are treated as water and values between 0.5 and 1.0 as land. The water areas are colored based on the water depth; land, based on its elevation. The random depth data are used to create clouds over the oceans. An atmosphere approximately like the Earth's is simulated; its light absorption is calculated to create a blue cast around the limb of the planet. A function that rises from 0 to 1 based on latitude is modulated by the local elevation to generate polar ice caps—high altitude terrain carries glaciers farther from the pole. Based on the position of the star with respect to the observer, the apparent color of each pixel of the planet is calculated by ray-tracing from the star to the planet to the observer and applying a lighting model that sums ambient light and diffuse reflection (for most planets ambient light is zero, as their primary star is the only source of illumination). Additional random data are used to generate stars around the planet.
Night A sequence of pseudorandom numbers is used to generate stars with a user-specified density.

Cloud pictures always contain 256 or fewer colors and may be displayed on most color-mapped devices without further processing. Planet pictures often contain tens of thousands of colors that must be compressed with ppmquant or ppmdither before encoding in a color-mapped format. If the display resolution is high enough, ppmdither generally produces better-looking planets. ppmquant tends to create discrete color bands, particularly in the oceans, which are unrealistic and distracting. The number of colors in starry sky pictures generated with the -night option depends on the value specified for
-saturation. Small values limit the color temperature distribution of the stars and reduce the number of colors in the image. If the -saturation is set to 0, none of the stars will be colored and the resulting image will never contain more than 256 colors. Night sky pictures with many different star colors often look best when color-compressed by pnmdepth rather than ppmquant or ppmdither.Try newmaxval settings of 63, 31, or 15 with pnmdepth to reduce the number of colors in the picture to 256 or fewer.

OPTIONS

-clouds Generate clouds. A pixmap of fractal clouds is generated. Selecting clouds sets the default for fractal dimension to 2.15 and power scale factor to 0.75.
-dimension dimen Sets the fractal dimension to the specified dimen, which may be any floating-point value between 0 and 3. Higher fractal dimensions create more "chaotic" images, which require higher resolution output and a larger FFT mesh size to look good. If no dimension is specified, 2.4 is used when generating planets and 2.15 for clouds.
-glaciers level The floating-point level setting controls the extent to which terrain elevation causes ice to appear at lower latitudes. The default value of 0.75 makes the polar caps extend toward the equator across high terrain and forms glaciers in the highest mountains, as on Earth. Higher values make ice sheets that cover more and more of the land surface, simulating planets in the midst of an ice age. Lower values tend to be boring, resulting in unrealistic geometrically precise ice cap boundaries.
-hour hour When generating a planet, hour is used as the hour angle at the central meridian. If you specify -hour 12, for example, the planet will be fully illuminated, corresponding to high noon at the longitude at the center of the screen. You can specify any floating-point value between 0 and 24 for hour, but values which place most of the planet in darkness (0 to 4 and 20 to 24) result in crescents which, while pretty, don't give you many illuminated pixels for the amount of computing that's required. If no -hour option is specified, a random hour angle is chosen, biased so that only 25 percent of the images generated will be crescents.

Previous | Table of Contents | Next