All options can be abbreviated to their shortest unique prefix. You

may use two hyphens instead of one. You may separate an option name

and its value with white space instead of an equals sign.

This program is part of

the specified binary arithmetic operation on their sample values and

produces an output of a format which is the more general of the two

input formats. The two input images must be of the same width and

height. The arithmetic is performed on each pair of identically

located tuples to generate the identically located tuple of the out-

put.

For the purpose of the calculation, it assumes any PBM, PGM, or PPM

input image is the equivalent PAM image of tuple type

output, produces the equivalent of the PAM image which is the result

of the calculation.

The first

second

If the output is PAM, the tuple type is the same as the tuple type of

the left input image.

tuples in the two input images.

The arithmetic operation is in all cases fundamentally a function from

two integers to an integer. The operation is performed on two tuples

as follows. The two input images must have the same depth, or one of

them must have depth one.

case.

If they have the same depth,

metic one sample at a time. I.e. if at a particular position the left

input image contains the tuple (s1,s2,...,sN) and the right input

image contains the tuple (t1,t2,...tN), and the function is f, then

the output image contains the tuple (f(s1,t1),f(s2,t2),...,f(sN,tN)).

If one of the images has depth 1, the arithmetic is performed between

the one sample in that image and each of the samples in the other.

I.e. if at a particular position the left input image contains the

tuple (s) and the right input image contains the tuple (t1,t2,...tN),

and the function is f, then the output image contains the tuple

(f(s,t1),f(s,t2),...,f(s,tN)).

The meanings of the samples with respect to the maxval varies accord-

ing to the function you select.

In PAM images in general, the most usual meaning of a sample (the one

that applies when a PAM image represents a visual image), is that it

represents a fraction of some maximum. The maxval of the image corre-

sponds to some maximum value (in the case of a visual image, it corre-

sponds to 'full intensity.'), and a sample value divided by the maxval

gives the fraction.

For

functions:

arguments and result as numbers in the range [0,1). For example, if

the maxval of the left argument image is 100 and the maxval of the

right argument image is 200 and the maxval of the output image is 200,

and the left sample value in an

sample is 60, the actual calculation is 50/100 + 60/200 = 160/200, and

the output sample value is 160.

For these functions,

imum of the two input maxvals, except with

uses an output maxval of 2. (Before Netpbm 10.14 (February 2003),

there was no exception for

that the maxval was

(January 2005), it changed to being exactly 2).

If the result of a calculation falls outside the range [0, 1),

In many cases, where both your input maxvals are the same, you can

just think of the operation as taking place between the sample values

directly, with no consideration of the maxval except for the clipping.

E.g. an

13.

But with

maxval 255, which means the output image also has maxval 255. Con-

sider a location in the image where the input sample values are 5 and

10. You might think the multiplicative product of those would yield

50 in the output. But

fractions 5/255 and 10/255. It multiplies those together and then

rescales to the output maxval, giving a sample value in the output PAM

of 50/255 rounded to the nearest integer: 0.

With the bit string operations, the maxval has a whole different mean-

ing. The operations in question are:

and

With these, each sample value in one or both input images, and in the

output image, represents a bit string, not a number. The maxval tells

how wide the bit string is. The maxval must be a full binary count (a

power of two minus one, such as 0xff) and the number of ones in it is

the width of the bit string. For the dyadic bit string operations

(that's everything but the shift functions), the maxvals of the input

images must be the same and

image the same.

For the bit shift operations, the output maxval is the same as the

left input maxval. The right input image (which contains the shift

counts) can have any maxval and the maxval is irrelevant to the inter-

pretation of the samples. The sample value is the actual shift count.

But it's still required that no sample value exceed the maxval.

Most of the operations are obvious from the option name. The follow-

ing paragraphs cover those that aren't.

the left input image.

produce nonobvious results because of the way

ple values. See Maxval .

left input image. But like

results. Note that

use when the left argument (dividend) is greater than the right argu-

ment (divisor) -- the result in that case is always the maxval. If

the divisor is 0, the result is the maxval. This option was new in

Netpbm 10.30 (October 2005).

is less than the value in the right input image,

equal, and

If the maxvals of the input images are not identical,

claim two values are not equal when in fact they are, due to the pre-

cision with which it does the arithmetic. However, it will never say

A is greater than B if A is less than B.

to contain bit strings; they compute bitwise logic operations. Note

that if the maxval is 1, you can also look at these as logic opera-

tions on boolean input values. See section Maxval for the special

meaning of maxval with respect to bit string operations such as these.

image to contain bit strings. They compute a bit shift operation,

with bits falling off the left or right end and zeroes shifting in, as

opposed to bits off one end to the other. The right input image sam-

ple value is the number of bit positions to shift.

Note that the maxval (see Maxval ) determines the width of the frame

within which you are shifting.

If you want to apply a unary function, e.g. "halve", to a single

image, use

In Netpbm 10.3 through 10.8, though,

ible because it required the input images to be of the same depth, so

you could not multiply a PBM by a PPM as is often done for masking.

(It was not intended at the time that

Netpbm -- the plan was just to rewrite it to use

removed by mistake).

But starting with Netpbm 10.9 (September 2002),

images to have different depths as long as one of them has depth 1,

and that made it backward compatible with

The original

The

The bit string operations were added in Netpbm 10.27 (March 2005).

The

netpbm documentation 08 April 2007 Pamarith User Manual(0)