cvtool 1.0.0

Table of Contents

Next: , Up: (dir)


This manual was last updated March 20, 2009 for version 1.0.0 of cvtool.

Copyright © 2005, 2006, 2007, 2008, 2009, 2010 Martin Lambers

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

Next: , Previous: Top, Up: Top

1 Overview

Next: , Up: Overview

1.1 Concept

Cvtool is a filter that manipulates one or more images (called frames): it reads frames from standard input and writes the manipulated frames to standard output. It can read and write streams of NetPBM (pbm, pgm, ppm, pnm, pam) and PFS frames.

Cvtool integrates all its functionality into a single binary, and makes it available through commands such as rotate, filter, and others.

The following command scales a NetPBM frame by a factor of 3:

     $ cvtool scale --factor 3.0 < input.ppm > output.ppm

This is how one would select a rectangle from an PFS frame stream:

     $ cvtool cut --left 10 --top 10 --width 100 --height 100 \
       < input.pfs > output.pfs

cvtool help prints a list of available commands, and cvtool help cmd prints help for the command cmd.

Next: , Previous: Concept, Up: Overview

1.2 Supported file types

Due to the use of OpenGL textures to store frame data, some limitations apply:

1.2.1 NetPBM formats: ‘pnm

All NetPBM image formats (pbm, pgm, ppm, pnm, pam) are supported, except for their old "plain" variants. Multiple images in one file are supported. They may differ in size and type.

If the input images use more than 8 bit per channel, they are treated as floating point images.

1.2.2 PFS format: ‘pfs

Cvtool supports the PFS format used by pfstools.

Currently, cvtool ignores channel tags. This will be fixed in a future version.

Next: , Previous: Supported file types, Up: Overview

1.3 Output

Cvtool normally prints messages to stderr. It prepends messages with its name, the level of information, and the name of the command.

The level of information is DBG for debugging messages, INF for informational messages, WRN for warnings, ERR for error messages, and REQ for requested information. Normally, cvtool prints only messages of level INF or higher, but this can be changed with --quiet and --verbose; see below.

Some commands, for example info, print special information messages that the user explicitly requests. Such special messages have the level REQ, and can usually be redirected using the --output option. In this case, no additional information will be prepended to the messages.

The special filename - means standard output (stdout). Redirecting messages to stdout is only allowed when no frames are written to stdout.

Next: , Previous: Output, Up: Overview

1.4 Global options

Reduces the amount of output: only messages with level WRN and higher will be printed.
Increases the amount of output: all messages will be printed, even those with level DBG. This will include progress information in many cases, but much of the output is really only useful for debugging purposes.

Next: , Previous: Global options, Up: Overview

1.5 Common parameters

1.5.1 Arrays and Matrices

Some commands need arrays of integer or floating point values as parameters. Matrices are treated as two-dimensional arrays. Higher dimensions are also possible.

All of these array types are treated the same: the first part of the argument determines the number of dimensions of the array and its size in each dimension. The second part lists all values, separated by commas.

If the command requests an array or matrix of fixed dimension and size (or of dimension 1 and arbitrary size), then the first part can be omitted: only the value list is necessary in this case.


1.5.2 Colors

Colors can be given in one of three forms:

  1. SVG color names
    The SVG 1.1 specification of the W3C defines 147 color names. Cvtool accepts each of these names, case insensitively. The full list can be found here:
  2. Hex triplets
    The RGB components of a color can be specified directly as a hex triplet: 0xrrggbb. For example, 0x00ff00 is green, 0xffffff is white, and 0x000000 is black.
  3. Decimal values
    The RGB components of a color can be specified as decimal values, prepended with r, g, or b. For example, g255 is green (the red and blue components default to zero), r255g255b255 is white, and r0g0b0 is black.

Next: , Previous: Common parameters, Up: Overview

1.6 Environment

Directory to create temporary files in.
Cvtool tries to format its messages so that they do not use more than the given number of columns. If this variable is unset, a default of 80 will be used.

Previous: Environment, Up: Overview

1.7 Exit codes

Cvtool returns 0 on success and 1 on error.

Next: , Previous: Overview, Up: Top

2 Commands

Next: , Up: Commands

2.1 Informational Commands

Next: , Up: Informational Commands

2.1.1 help

help [command]

Print general or command specific help.

Next: , Previous: help, Up: Informational Commands

2.1.2 version


Print version information.

Previous: version, Up: Informational Commands

2.1.3 info

info [-s|--statistics] [-S|--single] [-o|--output=file]

Print information about frames in the input stream.

If ‘--single’ is used, the command exits after the first frame has been processed. If ‘--statistics’ is used, additional statistics about the frame contents are printed. The output can be redirected to a file or to standard output (-) using the ‘--output’ option.

The following information will be printed: STREAM (pfs or pnm), CHANNELS (0-4), FORMAT (luminance or color), TYPE (uint8 or float), WIDTH, HEIGHT.

Statistics are computed for each available channel c: CHc_MIN, CHc_MAX, CHc_MEAN, CHc_MEDIAN, CHc_STDDEVIATION.


     $ cvtool info < file.pnm
     cvtool: [REQ] info: STREAM=pnm CHANNELS=3 FORMAT=color TYPE=uint8 WIDTH=394 HEIGHT=454
     $ eval `cvtool info -o - < file.pnm`
     $ echo $WIDTH

Next: , Previous: Informational Commands, Up: Commands

2.2 Stream Manipulation

Next: , Up: Stream Manipulation

2.2.1 combine

combine [-m|--method=(lr|leftright)|(tb|topbottom)] [-j|--justify=(left|top)|center|(right|bottom)] [-c|--color=color] file...

Combine the given files by placing the frames side by side (‘leftright’) or one below the other (‘topbottom’).

The default is ‘leftright’. If the frames have different sizes, then the smaller ones have to be aligned with the biggest one. The default is to center them. The remaining space will be filled with the given color; the default is black.


     $ cvtool combine left.pnm right.pnm > lr.pnm
     $ cvtool combine -m tb \
       <(cvtool combine a.pnm b.pnm) \
       <(cvtool combine c.pnm d.pnm) \
       > 2x2.pnm

Next: , Previous: combine, Up: Stream Manipulation

2.2.2 convert

convert [-t|--type=uint8|float] [-f|--format=lum|color|data]

Converts the input frames to another type and format. The default is to keep the input type and format. The output will be PNM for type uint8 and PFS for type float. If the format is set to ‘data’, no color space conversion will take place.


     $ cvtool convert -t float < in.pnm > out.pfs

Next: , Previous: convert, Up: Stream Manipulation

2.2.3 create

create [-t|--type=uint8|float] [-f|--format=lum|color] [-n|--n=n] -w|--width=w -h|--height=h [-c|--color=<color>]

Create n (default 1) frames with the given format (default color) and the given type (default uint8). The frames will have the given width and height, and they will be filled with the given color (default black). The resulting stream type will be PNM if the type is uint8, and PFS otherwise.


     $ cvtool create -t uint8 -f lum -w 720 -h 576 > out.pgm
     $ cvtool create -t float -f color -w 10 -h 10 -c green > green.pfs

Next: , Previous: create, Up: Stream Manipulation

2.2.4 foreach

foreach [-s|--shell=shell] [-n|--n=n] cmd

Execute the given command for every frame.

The command is expected to read n frames from standard input (default is n=1), and write an arbitrary number (including zero) of frames to standard output. The original frame(s) that were given to the command are replaced by the output of the command. The frames that the command produces are converted to the format of the original frames. The foreach command replaces the following special strings in the command cmd before executing the command: %N (replaced with frame number), %W (replaced with frame width), and %H (replaced with frame height). If n is greater than 1, these values refer to the first frame that is piped to the command. The command cmd is executed by passing it to the system shell. The default is ‘/bin/sh -c’ on most systems. This can be overridden with the --shell option. It expects a string with zero or one spaces: The first part of the string is the shell, the second part (if any) is the first option to the shell. The next option will then be the command to execute.


     # Rotate a video. Resize after rotation to keep the original dimensions.
     $ cvtool foreach 'cvtool rotate -a %N | cvtool resize -w 352 -h 240' \
       < video.pnm > rotating-video.pnm

Next: , Previous: foreach, Up: Stream Manipulation

2.2.5 merge

merge [-s|--shuffle] [-o|--output=file] file...

Merges files into one stream, in the given order.

If --shuffle is used, the order will be randomized. The file names will be printed to stderr in the order they are merged. If --output is used, the file names will be written to the given file instead.


     $ ls
     frame000.pnm frame001.pnm frame002.pnm
     $ cvtool merge frame*.pnm > video.pnm

Next: , Previous: merge, Up: Stream Manipulation

2.2.6 reverse


Reverses the order of the frames in the stream.

This requires a temporary file that is big enough to hold the complete input stream.


     $ cvtool reverse < video.pnm > oediv.pnm

Next: , Previous: reverse, Up: Stream Manipulation

2.2.7 select

select [-d|--drop] [-f|--fps=fps] range...

Selects frames from a stream.

By default, frames in the given ranges are kept and all others dropped. With --drop, frames in the given ranges are dropped and all others kept.

A range must be of the following form: l-h (from l to h), -h (from beginning to h), l- (from l to end), l (only l), or - (everything). Each start and end point can be a frame number (counting from 0) or a time in the format [hours:]minutes:seconds[.fraction]. In short: if it contains a colon, it's a time. Time ranges can only be used if the ‘--fps’ option is used to specify the number of frames per second.
IMPORTANT: If you use frame number ranges, the high frame number is inclusive: the frame with this number will be dropped/kept. If you use time ranges, the high time is exclusive and marks the first frame that will not be dropped/kept.


     # Drop the frames 0 to 124 from the stream (with a framerate of 25 fps,
     # these are the first five seconds).
     $ cvtool select --drop 0-124 < in.pnm > out.pnm
     # Drop the first 5 seconds of the stream (with a framerate of 25 fps,
     # these are the frames 0 to 124. The frame at 0:05, with the frame
     # number 125, will be the first that is kept!)
     $ cvtool select --fps 25 --drop 0:00-0:05 < in.pnm > out.pnm
     # Keep the second 5-minutes-block and drop all the rest. Both
     # commands are equivalent.
     $ cvtool select --fps 25 5:00-10:00 < in.pnm > out.pnm
     $ cvtool select --fps 25 --drop -5:00 10:00- < in.pnm > out.pnm

Previous: select, Up: Stream Manipulation

2.2.8 split

split [-n|--n=n] [-t|--template=template] [-b|--backwards] [-s|--start=i]

Split the input stream into multiple files.

Each new files contains n frames (default is n=1). The filename will be generated from the template: the template must contain exactly one appearance of the character %. This character must be followed by one of the digits 1 through 9. The digit must be followed by the uppercase character N. This special string %xN will be replaced by the number of the first frame of the stream contained in this file. The number will be left-padded with zeros until its width is at least x characters. The default template is ‘frame-%6N’.
A start number i for the first frame can be given, and the frames can be counted backwards. If the frames are counted backwards, a start number is required, because negative frame numbers are not accepted.


     $ cvtool split -t frame%3N.pnm < ../video.pnm
     $ ls
     frame000.pnm frame001.pnm frame002.pnm
     $ cvtool split -s 99 -b -t img%2N.pnm < ../video.pnm
     $ ls
     img99.pnm img98.pnm img97.pnm

Next: , Previous: Stream Manipulation, Up: Commands

2.3 Resizing Frames

Next: , Up: Resizing Frames

2.3.1 resize

resize -w|--width=w -h|--height=h [-x|--x-offset=x] [-y|--y-offset=y] [-c|--color=color]

Resize the frames to the given new width and height.

Place the original frame contents at the position (x,y) relative to the new frame (these offsets may be negative). If no or an incomplete position is given, compute the missing part(s) so that the old contents are centered on the new frame. Fill holes that might result with the given color (default is black).


     # Add a green border of 10 pixels to a 352x240 frame
     $ cvtool resize -w 372 -h 260 -c green < img.pnm > img2.pnm

Previous: resize, Up: Resizing Frames

2.3.2 cut

cut -l|--left=l -t|--top=t -w|--width=w -h|--height=h

Only let the given rectangle through; cut the rest of each frame.


     $ cvtool cut -l 0 -t 0 -w 10 -h 10 < in.pnm > out.pnm

Next: , Previous: Resizing Frames, Up: Commands

2.4 Transforming Frames

Most geometric transformation commands support the option ‘--interpolation’ to choose one of the following interpolation types:

The default interpolation type is bilinear.

Next: , Up: Transforming Frames

2.4.1 affine

affine -m|--matrix=2x2-matrix [-c|--color=color] [-i|--interpolation=i]

Apply the affine tranformation defined by the given matrix (4 floating point values separated by commas) to the frames. The frame dimensions will be adapted so that the resulting frame will fit. Possible holes will be filled with the given color; the default is black.


     $ cvtool affine -m 2.0,0.1,0.75,1.0 < in.pnm > out.pnm

Next: , Previous: affine, Up: Transforming Frames

2.4.2 flip


Flip frames (left/right).


     $ cvtool flip < in.pnm > out.pnm

Next: , Previous: flip, Up: Transforming Frames

2.4.3 flop


Flop frames (top/bottom).


     $ cvtool flop < in.pnm > out.pnm

Next: , Previous: flop, Up: Transforming Frames

2.4.4 rotate

rotate -a|--angle=angle [-c|--color=color] [-i|--interpolation=i]

Rotate frames with the given angle (in degrees), counterclockwise.

The dimensions of the rotated frame will be big enough to hold all informations from the source. "Holes" will be filled with the given color; the default is black.


     $ cvtool rotate -a -45 < in.pnm > out.pnm

Next: , Previous: rotate, Up: Transforming Frames

2.4.5 scale

scale [-w|--width=w] [-h|--height=h] [-i|--interpolation=i]
scale -x|--factor-x=factor-x -y|--factor-y=factor-y [-i|--interpolation=i
scale -f|--factor=factor [-i|--interpolation=i]

Scale frames to new size.

First form: Give new width and/or height. If one value is missing, it is computed from the other so that the aspect ratio remains the same.

Second form: Give scale factors for width and height.

Third form: Give one scale factor for both width and height.


     # The following three commands do the same for a 400x200 frame:
     $ cvtool scale -w 100 -h 50    < in.pnm > out.pnm
     $ cvtool scale -x 0.25 -y 0.25 < in.pnm > out.pnm
     $ cvtool scale -f 0.25         < in.pnm > out.pnm

Previous: scale, Up: Transforming Frames

2.4.6 shear

shear [-x|--shear-x=angle-x] [-y|--shear-y=angle-y] [-c|--color=color] [-i|--interpolation=i]

Shear frames in horizontal and/or vertical direction.

The frames are sheared with the given angle(s) from (-90,90). Negative angles shear clockwise. "Holes" will be filled with the given color; the default is black.


     $ cvtool shear -x 20 -y 10 < in.pnm > out.pnm

Next: , Previous: Transforming Frames, Up: Commands

2.5 Mixing Frames

Next: , Up: Mixing Frames

2.5.1 blend

blend -s|--source=file [-a|--alpha=file] [-S|--single] [-x|--x=x] [-y|--y=y]

Blends the source into the frame stream, using an alpha map.

With no alpha map, the source is simply copied into the frames. x and y specify the position that the source should be copied to. The default is (0,0). Positions outside of the frames are possible: parts of the source that do not fit into the frames will be ignored. When --single is used, only the first frame of the source will be used; this frame will be copied into all frames of the stream.


     $ cvtool blend --single -s logo.pnm -a logo-alpha.pgm -x 700 -y 0 \
       < video.pnm > video-with-logo.pnm

Next: , Previous: blend, Up: Mixing Frames

2.5.2 layer

layer -m|--mode=min|max|median|or|and|xor|diff|add|xadd|sub|xsub|mul|div file...

Layers the frames from the given files on top of each other, using the given mode.

Layering will be done for each channel separately. The input frames may differ in size. In this case, they will be implicitly scaled to a common size. Graylevel frames have

The modes are as follows:


     $ cvtool layer --mode=or red.pnm green.pnm blue.pnm \
       > allchannels.pnm

Previous: layer, Up: Mixing Frames

2.5.3 mix

mix -w|--firstweight=fw... [-W|--lastweight=lw...] [-s|--steps=s] [-b|--bias=b] file...

Mixes the given sources into a single stream using the given weights.

The default is to produce a single step, i.e. one output frame for each set of input frames. If more steps are requested, the weights are interpolated between the set of first weights and the set of last weights. By default, this interpolation is done linearly, which corresponds to a bias setting of 0.5. Smaller bias values will give more attention to the first weights, larger values more to the last weigths. The bias must be from (0,1).

The input frames may differ in size. In this case, they will be implicitly scaled to a common size.


     $ cvtool mix --weight=1,1 black.pgm white.pgm > gray.pgm
     $ cvtool mix -w 1,0 -W 0,1 -s 10 black.pgm white.pgm \
       > from-black-to-white.pgm

Next: , Previous: Mixing Frames, Up: Commands

2.6 Color Manipulation

Next: , Up: Color Manipulation

2.6.1 channelextract

channelextract -c|--channel=0|1|2|3|r|g|b|lum

Extract the given channel from the input. If ‘channel’ is 0, 1, 2, or 3, then the data is copied unmodified. If the ‘channel’ is r, g, b, or lum, then the input is first converted to the red, gree, blue, or luminance form.


     $ cvtool channelextract -c r < color.ppm > red.pgm

Next: , Previous: channelextract, Up: Color Manipulation

2.6.2 channelcombine

channelcombine file0 [file1 [file2 [file3]]]

Extract the first channel from the given files and combine them into multichannel output data.


     $ cvtool channelcombine red.pgm green.pgm blue.pgm > rgb.ppm

Next: , Previous: channelcombine, Up: Color Manipulation

2.6.3 color

color [-h|--hue=h] [-s|--saturation=s] [-l|--lightness=l] [-c|--contrast=c]

Color adjustment.

Hue, saturation, lightness, and constrast are manipulated in the HSL (Hue, Saturation, Lightness) color space. h is an additive constant to the hue angle, in degrees. s, l, c measure the relative change in saturation, lightness, contrast: -1 means the result will be zero, 0 means the result will be the same as the original, and +1 means that the result will be two times as high as the original. Values greater than +1 are possible. For example, s = -1 will convert the input frames to graylevels. See the Wikipedia entry for HSL color space for more information.


     $ cvtool color -h 120 < red.pnm > green.pnm
     $ cvtool color -h 120 < green.pnm > blue.pnm
     $ cvtool color -h 120 < blue.pnm > red.pnm
     $ cvtool color -s -1 < colored.pnm > gray.pnm
     $ cvtool color -l +1 < dark.pnm > light.pnm

Next: , Previous: color, Up: Color Manipulation

2.6.4 gamma


Gamma correction.


     $ cvtool gamma -g 2.2 < dark.pnm > bright.pnm

Previous: gamma, Up: Color Manipulation

2.6.5 invert


Invert input frames.


     $ cvtool invert < in.pnm > out.pnm

Next: , Previous: Color Manipulation, Up: Commands

2.7 Drawing

Up: Drawing

2.7.1 draw

draw [-w|--width=width] [-d|--dash=dash-specification] [-l|--line-cap=butt|round|square] [-L|--line-join=miter|round|bevel] [-s|--border-style=none|color|pattern|multipattern|linear-gradient|radial-gradient] [-c|--border-color=color] [-p|--border-pattern=file] [-g|--border-gradient=gradient-specification] [-S|--fill-style=none|color|pattern|multipattern|linear-gradient|radial-gradient] [-C|--fill-color=color] [-P|--fill-pattern=file] [-G|--fill-gradient=gradient-specification] [-f|--font-family=font] [-t|--font-slant=normal|italic|oblique] [-W|--font-weight=normal|bold] [-F|--font-size=size|size-x,size-y] [-j|--justify-x=left|right|center] [-J|--justify-y=bottom|top|center] [-a|--antialias] [-u|--unit] command...

Draw simple geometric forms, lines and curves, and/or text.

The style for the object lines and the filling can be specified separately; it is either ‘none’ (line/filling is not drawn), ‘color’ (solid color), ‘pattern’ (a pattern read from a file), ‘multipattern’ (a different pattern for each input frame, all read from a file), ‘linear-gradient’ (a linear gradient), or ‘radial-gradient’ (a radial gradient). The default is the solid color black for lines and no filling.

A linear gradient specification x0,y0,color0,x1,y1,color1 defines a gradient along the line from start point x0,y0 (with color color0 to end point x1,y1 (with color color1). Any number of additional color stops can be added by appending an offset value and its associated color to the gradient specification. The offsets must be between 0.0 and 1.0 and describe the position on the gradient line, where 0.0 is the start point and 1.0 is the end point.

A radial gradient specification x0,y0,r0,color0,x1,y1,r1,color1 defines a gradient from the start cirlce x0,y0,r0 with color color0 to the end circle x1,y1,r1 with color color1. Additional stops can be added in the same way as for linear gradients.

The style of lines can be further adjusted with the --width, --dash, --line-cap, and --line-join options. The --width option selects the line width; it is 2.0 by default. The --dash takes a list of values that specify alternating lengths for "line on" and "line off" segments of a line. If only one value is given, these lengths are equal. The --line-cap option selects the style of line and curve ends. The --line-join options selects the style of the meeting point of two line or curve segments.

Antialiasing can be turned on (default) and off with --antialias.

If --unit is given, then all coordinates and sizes on the command line refer to a frame of size 1x1. All values are then scaled so that they match the real frame dimensions. For example, the point (0.5,0.5) will always be in the middle of a frame, regardless of the frame dimensions.

Text is drawn relative to the current drawing position (previously set with move_to, for example). By default, the current drawing position sets the bottom left point of the first character of the text. This can be changed with the --justify-x and --justify-y options. The font family, slant, weight, and size can be chosen. Note that you may not get an error message if --font-family fails to set the given font, because the underlying library may not report this error. If you use two values for the font size, then the first applies to the horizontal direction and the second to the vertical direction, so that you can scale the font asymmetrically.

A drawing command consists of a command name and parameter sets that define one or more instances of the command.

Simple geometric forms:


Lines and curves:

Open lines and curves will automatically be closed when drawing geometric forms or text.

The draw command is only a simple interface to the excellent CAIRO graphics library. Much of the CAIRO documentation is useful for this command, too, especially the FAQ.


     # Draw two green circles with a line width of 5.
     $ cvtool draw -w 5 -c green circle 50,50,40 50,50,20 \
       < blank.pnm > circle.pnm
     # The same, but filled with linear gradient from red to yellow to blue.
     $ cvtool draw -w 5 -S linear-gradient \
       -G 10,50,red,90,50,blue,0.5,yellow circle 50,50,40 50,50,20 \
       < blank.pnm > circle.pnm
     # Display one video inside another video in the form of a circle.
     $ cvtool draw -s none -S multipattern -P video2.pnm circle 50,50,40 \
       < video1.onm > out.pnm
     # Print a string exactly centered in the middle of blank.pnm.
     $ cvtool draw -u -f "Serif" -F 0.1,0.1 -j center -J center \
       move_to 0.5,0.5 text "Hello world" \
       < blank.pnm > text.pnm

Next: , Previous: Drawing, Up: Commands

2.8 Filtering Frames

Next: , Up: Filtering Frames

2.8.1 gauss

filter gauss [-3|--3d] -k|--k=k
filter gauss [-3|--3d] -s|--sigma=s
filter gauss [-3|--3d] -x|--k-x=kx -y|--k-y=ky [-t|--k-t=kt]
filter gauss [-3|--3d] [-k|--k=k] [-x|--k-x=kx] [-y|--k-y=ky] [-t|--k-t=kt] [-s|--sigma=s] [--sigma-x=sx] [--sigma-y=sy] [--sigma-t=st]

Filter framess with a Gauss filter, in 2D or 3D (with the third dimension being the time). The kernel size can be given for each dimension, or once for all. It will be (2kx+1)x(2ky+1)[x(2kt+1)]. Different values for each direction lead to asymmetric filtering. The gauss filter can be specified by the sigma value(s): the mask size will be computed so that roughly 95% of the mass lies within the resulting mask. It is also possible to specify both sigma and k.


     $ cvtool gauss --3d -k 3 < video.pnm > smoothed-video.pnm

Next: , Previous: gauss, Up: Filtering Frames

2.8.2 mean

filter mean [-3|--3d] -k|--k=k
filter mean [-3|--3d] -x|--k-x=kx -y|--k-y=ky [-t|--k-t=kt]

Filter frames with a Mean filter, in 2D or 3D (with the third dimension being the time). The kernel size can be given for each dimension, or once for all. It will be (2kx+1)x(2ky+1)[x(2kt+1)]. Different values for each direction lead to asymmetric filtering.


     $ cvtool mean -k 2 < in.pnm > out.pnm

Next: , Previous: mean, Up: Filtering Frames

2.8.3 median

filter median [-a|--approximated] [-3|--3d] -k|--k=k
filter median [-a|--approximated] [-3|--3d] -x|--k-x=kx -y|--k-y=ky [-t|--k-t=kt]

Filter frames with a Median filter, in 2D or 3D (with the third dimension being the time). The kernel size can be given for each dimension, or once for all. It will be (2kx+1)x(2ky+1)[x(2kt+1)]. Different values for each direction lead to asymmetric filtering.

If the –approxmated option is given, then the median will be approximated. This helps to allow larger mask sizes.


     $ cvtool median -a -k 2 < in.pnm > out.pnm

Next: , Previous: median, Up: Filtering Frames

2.8.4 min

filter min [-3|--3d] -k|--k=k
filter min [-3|--3d] -x|--k-x=kx -y|--k-y=ky [-t|--k-t=kt]

Filter frames with a Minimum filter, in 2D or 3D (with the third dimension being the time). The kernel size can be given for each dimension, or once for all. It will be (2kx+1)x(2ky+1)[x(2kt+1)]. Different values for each direction lead to asymmetric filtering.


     $ cvtool min -k 2 < in.pnm > out.pnm

Next: , Previous: min, Up: Filtering Frames

2.8.5 max

filter max [-3|--3d] -k|--k=k
filter max [-3|--3d] -x|--k-x=kx -y|--k-y=ky [-t|--k-t=kt]

Filter frames with a Maximum filter, in 2D or 3D (with the third dimension being the time). The kernel size can be given for each dimension, or once for all. It will be (2kx+1)x(2ky+1)[x(2kt+1)]. Different values for each direction lead to asymmetric filtering.


     $ cvtool max -k 2 < in.pnm > out.pnm

Next: , Previous: max, Up: Filtering Frames

2.8.6 convolve

convolve -K|--kernel=K
convolve -X|--vector-x=X -Y|--vector-y=Y [-T|--vector-t=T]

Convolve frames with the given convolution kernel.

Both 2D and 3D kernels are accepted (the third dimension is the time). If the kernel is separable, the vectors that generate it can be given instead, to reduce computation costs. All kernel elements must be integers. The size of the kernel must be an odd number in each dimension.


     # Both commands are equivalent to 2D smoothing with the
     # mean filter with k=1:
     $ cvtool convolve -K 3x3:1,1,1,1,1,1,1,1,1 < in.pnm > out.pnm
     $ cvtool convolve -X 3:1,1,1 -Y 3:1,1,1    < in.pnm > out.pnm

Next: , Previous: convolve, Up: Filtering Frames

2.8.7 laplace

laplace [-c|--c=c]

Sharpens the input frames using the Laplace operator.

The sharpness factor c must be greater than or equal to zero. Larger values increase the effect. The default is 0.5.


     $ cvtool laplace -c 0.7 < smooth.pnm > sharp.pnm

Previous: laplace, Up: Filtering Frames

2.8.8 unsharpmask

unsharpmask -u|--unsharp=file [-c|--c=c]

Sharpens the input frames using unsharp masking.

The unsharp version of the input frames must be given using the ‘--unsharp’ option. It can be produced using e.g. a 3x3 Gauss filter. The sharpness parameter c must be from (0.5, 1.0). The default is 0.7.


     $ cvtool unsharpmask -u smoothsmooth.pnm -c 0.7 < smooth.pnm > sharp.pnm

Next: , Previous: Filtering Frames, Up: Commands

2.9 Frequency Domain

Up: Frequency Domain

2.9.1 wavelets

wavelets -t|--task=dwt -D|--daubechies=D-l|--level=l
wavelets -t|--task=idwt -D|--daubechies=D -l|--level=l
wavelets -t|--task=hard-thresholding -l|--level=l -T|--threshold=T wavelets -t|--task=soft-thresholding -l|--level=l -T|--threshold=T

Perform Discrete Wavelet Transform (DWT), Inverse Discrete Wavelet transform (IDWT), or manipulations on transformed data.

The parameter D chooses the Daubechies wavelet (D2, ..., D20; only even numbers). The level l must be at least 1. The threshold parameter for soft thresholding is applied to all input channels. The output of this command is always of type float; it has to be manually converted if necessary.


     $ cvtool wavelets -t dwt -D 2 -l 1 < in.pfs > dwt.pfs
     $ cvtool wavelets -t soft-thresholding -l 1 -T 0.5 < dwt.pfs > st.pfs
     $ cvtool wavelets -t idwt -D 2 -l 1 < st.pfs > out.pfs

Next: , Previous: Frequency Domain, Up: Commands

2.10 Detecting Image Features

Up: Detecting Image Features

2.10.1 edge

edge sobel
edge canny -s|--sigma=sigma -l|--low=l -h|--high=h

Detect edges.

Sobel will generate graylevel frames: the brighter a point, the stronger the edge.

Canny will generate binary frames. The sigma parameter is for Gauss smoothing. l and h are used for Hysterese thresholding; both must be from [0,1].

If the input is PFS, then the output will be PFS too and will contain both a channel containing the edge strengths and a channel containing the edge directions. If the input is PNM, then the output will be graylevel frames containing only the strength information.


     $ cvtool edge sobel < in.pgm > gray-edges.pgm
     $ cvtool edge canny -s 1.2 -l 4 -h 8 < in.pgm > bw-edges.pgm

Next: , Previous: Detecting Image Features, Up: Commands

2.11 Comparing Frames

Up: Comparing Frames

2.11.1 diff

diff [-s|--statistics] [-o|--output=file] file-1 file-2

Shows the differences between the two sources.

The sources must have the same pixel type, width, and height. This command produces frames of the same dimensions and of the same pixel type. Each pixel will be the absolute value of the difference of the corresponding pixels in the two sources. For RGB frames, the values will be computed for each channel separately.

If --statistics is used, the command will also compute the minimum, maximum, mean, and median error, and the standard deviation. For RGB frames, these values will be computed for each channel separately. For YUV frames, only the Y channel is considered. The output will be printed to stderr, unless it is redirected with the --output option. If the output is redirected to stdout (-), then only the statistics and no frames will be written to stdout.


     $ cvtool create -w 10 -h 10 -c r255g0b0 > red.pnm
     $ cvtool create -w 10 -h 10 -c r0g255b0 > green.pnm
     $ cvtool diff -s -o - red.pnm green.pnm
     frame pair 0: minimum error      = 1.0000 1.0000 0.0000
     frame pair 0: maximum error      = 1.0000 1.0000 0.0000
     frame pair 0: median error       = 1.0000 1.0000 0.0000
     frame pair 0: mean error         = 1.0000 1.0000 0.0000
     frame pair 0: standard deviation = 0.0000 0.0000 0.0000

Next: , Previous: Comparing Frames, Up: Commands

2.12 High Dynamic Range (HDR) Images

Up: High Dynamic Range (HDR) Images

2.12.1 tonemap

tonemap -m|--method=schlick94 [--brightness=b]
tonemap -m|--method=tumblin99 [-l|--max-absolute-luminance=l] [--display-adaptation-level=d] [--max-displayable-contrast=c]
tonemap -m|--method=drago03 [-l|--max-absolute-luminance=l] [--max-display-luminance=d] [--bias=b]
tonemap -m|--method=reinhard05 [--intensity=i] [--light-adaptation=l] [--chromatic-adaptation=c]
tonemap -m|--method=ashikhmin02 [-l|--max-absolute-luminance=l] [--local-contrast=c]
tonemap -m|--method=durand02 [-l|--max-absolute-luminance=l] [--sigma-spatial=ss] [--sigma-color=sc] [--base-contrast=bc]
tonemap -m|--method=reinhard02 [--key-value=a] [--white=w] [--sharpness=s] [--epsilon=e]

Tone map frames.

High dynamic range (HDR) frames are read from standard input, and low dynamic range (LDR) frames are written to standard output. See the original papers for a description of the parameters. For some methods, the results should be gamma corrected.

The default for the maximum absolute luminance is to get it from the file (if specified), or else 150.0.

The default for schlick94 is b=100.0.

The defaults for tumblin99 are d=100.0, c=70.0.

The defaults for drago03 are d=200.0, b=0.85.

The defaults for reinhard05 are i=0.0, l=0.5, c=0.5.

The default for ashikhmin02 is c=0.5.

The defaults for durand02 are ss=0.3, sc=0.4, bc=2.0.

The defaults for reinhard02 are a=0.1, w=1.0, s=10.0, e=0.5.

See also:

Previous: High Dynamic Range (HDR) Images, Up: Commands

2.13 Miscellaneous

Next: , Up: Miscellaneous

2.13.1 sort

sort [-k|--key-channel=k]

Sort frame contents. The channel k is used as the sorting key. If k is -1, then all channels are sorted independently.


     $ cvtool sort < in.pnm > out.pnm

Previous: sort, Up: Miscellaneous

2.13.2 visualize

visualize scalar [-p|--pseudo-color] [-m|--min=m] [-M|--max=M] [-l|--log=base]
visualize vector2 -m|--mode=color
visualize vector2 -m|--mode=needle [-x|--sample-x=x] [-y|--sample-y=y] [-X|--dist-x=dx] [-Y|--dist-y=dy] [-f|--factor=f]

visualize scalar: Visualizes scalar values by transforming values from [m,M] to [0,1] and writing the result as graylevel frames. M and m are automatically determined from the input if they are not given. By default, the transformation is linear. If ‘--log’ is given, then the transformation will use the logarithm with the given base. If ‘--pseudo-color’ is given, then pseudo colors are used instead of gray levels.

visualize vector2: Reads vector fields and visualizes them. Visualization as colors: Each of the x,y,z components, which range from -1 to 1, are transformed to R,G,B values that range from 0 to 1. Visualization as needle diagrams: Every x-th vector in horizontal direction and every y-th vector in vertical direction will be represented by a needle. The needles will have a distance of dx pixels in horizontal and dy pixels in vertical direction. The needle length is the length of the vector after it was scaled with the factor f. The default values are x=y=dx=dy=10, f=1.0.

Next: , Previous: Commands, Up: Top

Appendix A Command index

Previous: Command index, Up: Top

Appendix B Copying Information

Next: , Up: Copying Information

GNU Free Documentation License

Version 1.2, November 2002
     Copyright © 2000,2001,2002 Free Software Foundation, Inc.
     51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.

    The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

    This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

    We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.


    This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

    A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

    A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

    The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

    The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

    A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

    Examples of suitable formats for Transparent copies include plain ascii without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

    The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.

    A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

    The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.


    You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

    You may also lend copies, under the same conditions stated above, and you may publicly display copies.


    If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

    If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

    If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

    It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.


    You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

    1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
    2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
    3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
    4. Preserve all the copyright notices of the Document.
    5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
    6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
    7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
    8. Include an unaltered copy of this License.
    9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
    10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
    11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
    12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
    13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
    14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
    15. Preserve any Warranty Disclaimers.

    If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.

    You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

    You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

    The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.


    You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

    The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

    In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”


    You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

    You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.


    A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

    If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.


    Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

    If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.


    You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.


    The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See

    Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

       Copyright (C)  year  your name.
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.2
       or any later version published by the Free Software Foundation;
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
       Texts.  A copy of the license is included in the section entitled ``GNU
       Free Documentation License''.

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with...Texts.” line with this:

         with the Invariant Sections being list their titles, with
         the Front-Cover Texts being list, and with the Back-Cover Texts
         being list.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

Previous: GNU Free Documentation License, Up: Copying Information


Version 3, 29 June 2007
     Copyright © 2007 Free Software Foundation, Inc.
     Everyone is permitted to copy and distribute verbatim copies of this
     license document, but changing it is not allowed.


The GNU General Public License is a free, copyleft license for software and other kinds of works.

The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program—to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.

For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.

Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.

Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.

The precise terms and conditions for copying, distribution and modification follow.


  1. Definitions.

    “This License” refers to version 3 of the GNU General Public License.

    “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.

    “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.

    To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.

    A “covered work” means either the unmodified Program or a work based on the Program.

    To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.

    To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.

    An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.

  2. Source Code.

    The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.

    A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.

    The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.

    The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.

    The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.

    The Corresponding Source for a work in source code form is that same work.

  3. Basic Permissions.

    All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.

    You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.

    Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.

  4. Protecting Users' Legal Rights From Anti-Circumvention Law.

    No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.

    When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.

  5. Conveying Verbatim Copies.

    You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.

    You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.

  6. Conveying Modified Source Versions.

    You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:

    1. The work must carry prominent notices stating that you modified it, and giving a relevant date.
    2. The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
    3. You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
    4. If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.

    A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.

  7. Conveying Non-Source Forms.

    You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:

    1. Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
    2. Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
    3. Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
    4. Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
    5. Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.

    A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.

    A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.

    “Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.

    If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).

    The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.

    Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.

  8. Additional Terms.

    “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.

    When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.

    Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:

    1. Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
    2. Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
    3. Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
    4. Limiting the use for publicity purposes of names of licensors or authors of the material; or
    5. Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
    6. Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.

    All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.

    If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.

    Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.

  9. Termination.

    You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).

    However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

    Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

    Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.

  10. Acceptance Not Required for Having Copies.

    You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.

  11. Automatic Licensing of Downstream Recipients.

    Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.

    An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.

    You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.

  12. Patents.

    A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.

    A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.

    Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.

    In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.

    If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.

    If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.

    A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.

    Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.

  13. No Surrender of Others' Freedom.

    If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.

  14. Use with the GNU Affero General Public License.

    Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.

  15. Revised Versions of this License.

    The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.

    If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.

    Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.

  16. Disclaimer of Warranty.


  17. Limitation of Liability.


  18. Interpretation of Sections 15 and 16.

    If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.


How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

     one line to give the program's name and a brief idea of what it does.
     Copyright (C) year name of author
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or (at
     your option) any later version.
     This program is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     General Public License for more details.
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:

     program Copyright (C) year name of author
     This program comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’.
     This is free software, and you are welcome to redistribute it
     under certain conditions; type ‘show c’ for details.

The hypothetical commands ‘show w’ and ‘show c’ should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.

You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see

The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read