imod [-a add] [-s sub] [-m mult] [-d div] [-A] [-e exp] [-r root] [file.s] > output.s
IMOD(1)
NAME
imod - modify a stream of short integers with arithmetic operations
On this page
SYNOPSIS
DESCRIPTION
imod reads a stream of 16-bit signed short integers and applies a sequence of arithmetic operations to each value, writing the modified short integers to standard output. If the optional file.s argument is given, imod reads from that file; otherwise it reads from standard input.
Any number of operations may be given on the command line, and they are applied to each value in the order they appear. For efficiency the operations are precomputed once into a 65536-entry lookup table that maps every possible input short to its result. Because the output is constrained to the signed 16-bit range (-32768 to 32767), results outside that range are clipped to the nearest limit and a count of high and low clipping events is printed to standard error when the program finishes.
imod refuses to run if either standard input or standard output is a terminal. It is the short-integer counterpart of bwmod(1) and dmod(1), operating on the same kind of data used by tools such as dsp(5).
OPTIONS
- -a val
-
Add val to each value.
- -s val
-
Subtract val from each value.
- -m val
-
Multiply each value by val.
- -d val
-
Divide each value by val. A val of zero aborts the program.
- -A
-
Replace each value with its absolute value.
- -e val
-
Raise each value to the power val (exponentiation).
- -r val
-
Take the val-th root of each value (equivalent to raising to the power 1/val). A val of zero aborts the program.
- -h, -?
-
Print a usage message and exit.
EXAMPLES
imod -m 2.0 -a 100 < terrain.s > brighter.s
Reads short integers from terrain.s, multiplies each by 2.0 and then adds 100, writing the result to brighter.s. The operations are applied in command-line order, so each value becomes 2*value + 100; any results that exceed the 16-bit range are clipped and reported on standard error.
imod -A -d 4 < signal.s | dpeak > peaks.s
Takes the absolute value of every sample in signal.s, divides each by 4 to bring the magnitudes down, and pipes the rectified stream directly into dpeak(1) for peak detection.
SEE ALSO
brlcad(1), bwmod(1), dmod(1), smod(1), umod(1), istats(1), dsp(5)
AUTHOR
BRL-CAD Team
COPYRIGHT
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.
BUG REPORTS
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org