.TL Pamperspective User Manual .SH 1 pamperspective .LP Updated: 2 September 2004 .br Table Of Contents .SH 2 NAME .LP pamperspective - a reverse scanline renderer for Netpbm images .SH 2 SYNOPSIS .LP .DS L \fBpamperspective\fR [\fB--bottom_margin=\fR\fInum\fR] [\fB--detail=\fR\fInum\fR] [\fB--frame_include=\fR\fIbool\fR] [\fB--height=\fR\fInum\fR] [\fB--include=[\fR\fIx1\fR,\fIy1\fR;\fIx2\fR,\fIy2\fR; ...]] [\fB--input_system=\fR\fIspec\fR] [\fB--input_unit=\fR\fIspec\fR] [\fB--interpolation=\fR\fIspec\fR] [\fB--left_margin=\fR\fInum\fR] [\fB--margin=\fR\fInum\fR] [\fB--output_system=\fR\fIspec\fR] [\fB--proportion=\fR\fIspec\fR] [\fB--ratio=\fR\fInum\fR] [\fB--right_margin=\fR\fInum\fR] [\fB--top_margin=\fR\fInum\fR] [\fB--width=\fR\fInum\fR] { { \fIupper_left_x\fR \fIupper_left_y\fR \fIupper_right_x\fR \fIupper_right_y\fR \fIlower_left_x\fR \fIlower_left_y\fR \fIlower_right_x\fR \fIlower_right_y\fR } | { {\fB--upper_left_x\fR|\fB--ulx\fR}\fB=\fR\fIupper_left_x\fR {\fB--upper_left_y\fR|\fB--uly\fR}\fB=\fR\fIupper_left_y\fR {\fB--upper_right_x\fR|\fB--urx\fR}\fB=\fR\fIupper_right_x\fR {\fB--upper_right_y\fR|\fB--ury\fR}\fB=\fR\fIupper_right_y\fR {\fB--lower_left_x\fR|\fB--llx\fR}\fB=\fR\fIlower_left_x\fR {\fB--lower_left_y\fR|\fB--lly\fR}\fB=\fR\fIlower_left_y\fR {\fB--lower_right_x\fR|\fB--lrx\fR}\fB=\fR\fIlower_right_x\fR {\fB--lower_right_y\fR|\fB--lry\fR}\fB=\fR\fIlower_right_y\fR } } [\fIinfile\fR] .DE .LP Minimum unique abbreviation of option is acceptable. (But note that shortest unique prefixes might be longer in future versions of the program.) You may use single hyphens instead of double hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value. All options starting with hyphens may be given in any order. .SH 2 DESCRIPTION .LP .LP This program is part of Netpbm. \fBpamperspective\fR reads a Netpbm image as input and produces a Netpbm image of the same format as output. .LP The values \fIupper_left_x\fR ... \fIlower_right_y\fR, that are required on the command line, specify a quadrilateral in the input image. \fBpamperspective\fR interprets the input image as a perspective projection of a three dimensional scene, for example a photograph. \fBpamperspective\fR assumes the specified quadrilateral represents a parallelogram in that scene. The output image consists of this parallelogram, sheared to a rectangle. In this way \fBpamperspective\fR undoes the effect of a raytracer or scanline renderer. .LP The input is from \fIinfile\fR, or from Standard Input, if \fIinfile\fR is not specified. The output is to Standard Output. .SH 2 OPTIONS .LP .LP For options of the form \fB--name=\fR\fInum\fR, You can specify the value \fInum\fR in any of the traditional ways. Additionally, you can specify it as \fInum1\fR/\fInum2\fR, where \fInum1\fR and \fInum2\fR are specified traditionally. This is useful for specifying a width/height ratio of 4/3, without having to write infinitely many digits. Where \fInum\fR is supposed to be a natural number, \fBpamperspective\fR does not allow this format. .SH 3 Quadrilateral specification options .LP .RS .IP "\fB--upper_left_x=\fR\fInum\fR" .IP "\fB--ulx=\fR\fInum\fR" This specifies the horizontal coordinate of the upper left vertex of the quadrilateral. The meaning of 'upper left' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--upper_left_y=\fR\fInum\fR" .IP "\fB--uly=\fR\fInum\fR" This specifies the vertical coordinate of the upper left vertex of the quadrilateral. The meaning of 'upper left' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--upper_right_x=\fR\fInum\fR" .IP "\fB--urx=\fR\fInum\fR" This specifies the horizontal coordinate of the upper right vertex of the quadrilateral. The meaning of 'upper right' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--upper_right_y=\fR\fInum\fR" .IP "\fB--ury=\fR\fInum\fR" This specifies the vertical coordinate of the upper right vertex of the quadrilateral. The meaning of 'upper right' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--lower_left_x=\fR\fInum\fR" .IP "\fB--llx=\fR\fInum\fR" This specifies the horizontal coordinate of the lower left vertex of the quadrilateral. The meaning of 'lower left' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--lower_left_y=\fR\fInum\fR" .IP "\fB--lly=\fR\fInum\fR" This specifies the vertical coordinate of the lower left vertex of the quadrilateral. The meaning of 'lower left' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--lower_right_x=\fR\fInum\fR" .IP "\fB--lrx=\fR\fInum\fR" This specifies the horizontal coordinate of the lower right vertex of the quadrilateral. The meaning of 'lower right' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--lower_right_y=\fR\fInum\fR" .IP "\fB--lry=\fR\fInum\fR" This specifies the vertical coordinate of the lower right vertex of the quadrilateral. The meaning of 'lower right' is relative to the output image. The interpretation of \fInum\fR depends on the values for \fB--input_system\fR and \fB--input_unit\fR. .IP "\fB--input_system=\fR\fIsystem\fR" .IP "\fB--input_unit=\fR\fIunit\fR" The input image consists of pixels, which are, from the point of view of a scanline renderer, solid squares. These options specify how the coordinates are interpreted: .RS .IP "\fIsystem\fR=\fBlattice\fR, \fIunit\fR=\fBimage\fR" (0,0) refers to the upper left corner of the upper left pixel and (1,1) refers to the lower right corner of the lower right pixel. .IP "\fIsystem\fR=\fBlattice\fR, \fIunit\fR=\fBpixel\fR" (0,0) refers to the upper left corner of the upper left pixel and (\fIwidth\fR,\fIheight\fR) refers to the lower right corner of the lower right pixel. Here \fIwidth\fR and \fIheight\fR are the width and height of the input image. .IP "\fIsystem\fR=\fBpixel\fR, \fIunit\fR=\fBimage\fR" (0,0) refers to the centre of the upper left pixel and (1,1) refers to the centre of the lower right pixel. .IP "\fIsystem\fR=\fBpixel\fR, \fIunit\fR=\fBpixel\fR" (0,0) refers to the centre of the upper left pixel and (\fIwidth\fR-1,\fIheight\fR-1) refers to the centre of the lower right pixel. Here \fIwidth\fR and \fIheight\fR are the width and height of the input image. .RE The defaults are \fB--input_system\fR=\fBlattice\fR and \fB--input_unit\fR=\fBpixel\fR. Point-and-click front ends should use \fB--input_system\fR=\fBpixel\fR. .RE .SH 3 Frame options .LP By default \fBpamperspective\fR outputs exactly the above parallelogram, sheared to a rectangle. With the following options, it is possible to make \fBpamperspective\fR output a larger or smaller portion, which we call the "visible part." We refer to the default rectangle as the "frame." The visible part is always a rectangle the axes of which are parallel to those of the frame. .LP The frame options are additive. All the parts of the image specified by either margin options, \fB--include_frame\fR, or \fB--include\fR (or their defaults) are in the visible part. The visible part is the smallest possible rectangle that contains the parts specified those three ways. .LP The visible part must have nonzero size. That means if you specify \fB--frame-include=no\fR (overriding the default), you'll need to specify other frame options in order to have something in the visible part. .RS .IP "[\fB--margin=\fR\fInum\fR]" This specifies an area surrounding the frame that is to be included in the visible part. The units of \fInum\fR are the width of the frame for the horizontal extensions and the height of the frame for vertical extensions. .LP For example, \fB--margin=1\fR makes the visible part 9 times as large, because it makes the visible part extend one frame's worth to the left of the frame, one frame's worth to the right, one frame's worth above the frame, and one frame's worth below the frame, for a total of 3 frames' worth in both dimensions. .LP A negative value has an effect only if you specify \fB--frame_include=no\fR. The default is no margin. .LP The individual margin options below override this common margin setting. .IP "[\fB--top_margin=\fR\fInum\fR]" .IP "[\fB--left_margin=\fR\fInum\fR]" .IP "[\fB--right_margin=\fR\fInum\fR]" .IP "[\fB--bottom_margin=\fR\fInum\fR]" These are like \fB--margin\fR, but they specify only one of the 4 sides. The default value for each is the value (or default) of \fB--margin\fR. .IP "[\fB--frame_include=\fR\fIbool\fR]" Valid values for \fIbool\fR are: .RS .IP "\fByes\fR" .IP "\fBtrue\fR" .IP "\fBon\fR" The frame itself is in the visible part. .IP "\fBno\fR" .IP "\fBfalse\fR" .IP "\fBoff\fR" The frame itself is not necessarily in the visible part (but it could be if other options cause it to be). .RE The default value is \fByes\fR .IP "\fB--include=[\fR\fIx1\fR,\fIy1\fR;\fIx2\fR,\fIy2\fR; ...]" The visible part is made large enough such that every point (\fIx1\fR,\fIy1\fR), (\fIx2\fR,\fIy2\fR), of the input image is visible. The meaning of \fIx\fR and \fIy\fR is determined by \fB--input_system\fR and \fB--input_unit\fR. You can specify any number of semicolon-delimited points, including zero. .LP If you're supplying these options via a Unix command shell, be sure to use proper quoting, because semicolon (\fB;\fR) is usually a shell control character. .RE .LP The frame options were new in Netpbm 10.25 (October 2004). .SH 3 Output size options .LP .RS .IP "\fB--width=\fR\fIwidth\fR" .IP "\fB--height=\fR\fIheight\fR" These specify the size of the output image in horizontal and vertical direction. The values are numbers of pixels, so only natural numbers are valid. These values override the default means to determine the output size. .IP "\fB--detail=\fR\fInum\fR" If you do not specify \fB--width\fR, \fBpamperspective\fR determines the width of the output image such that moving \fInum\fR output pixels horizontally does not change the corresponding pixel coordinates of the input image by more than 1. \fBpamperspective\fR determines the height of the output image analogously. The default value is 1. .IP "\fB--proportion=\fR\fIprop\fR" .IP "\fB--ratio=\fR\fIratio\fR" Valid values for \fIprop\fR are: .RS .IP "\fBfree\fR" In this case \fB--ratio\fR does not have any effect. .IP "\fBfixed\fRAfter the width and height are determined" according to \fB--detail\fR, one of both will be increased, in order to obtain width/height=\fIratio\fR. .RE The defaults are \fB--proportion\fR=\fBfree\fR and \fB--ratio\fR=1. .RE .SH 3 Output options .LP .RS .IP "\fB--output_system=\fR\fIspec\fR" The output image consists of pixels, which are, from the point of view of a scanline renderer, solid squares. This option specifies how the four vertices of the quadrilateral correspond to the pixels of the output image. Valid values for \fIspec\fR are: .RS .IP "\fBlattice\fR" The upper left vertex corresponds to the upper left corner of the upper left pixel and The lower right vertex corresponds to the lower right corner of the lower right pixel. .IP "\fBpixel\fR" The upper left vertex corresponds to the centre of the upper left pixel and The lower right vertex corresponds to the centre of the lower right pixel. .RE The default value is \fBlattice\fR. Point-and-click front ends should use \fBpixel\fR. .IP "\fB--interpolation=\fR\fIspec\fR" Usually (centres of) output pixels do not exactly correspond to (centres of) input pixels. This option determines how the program will choose the new pixels. Valid values for \fIspec\fR are: .RS .IP "\fBnearest\fR" The output pixel will be identical to the nearest input pixel. .IP "\fBlinear\fR" The output pixel will be a bilinear interpolation of the four surrounding input pixels. .RE The default value is \fBnearest\fR. .RE .SH 2 HINTS .LP .LP It might be tempting always to use the options \fB--include 0,0;0,1;1,0;1,1\fR (assuming \fB--input_system=lattice\fR and \fB--input_unit=image\fR), so that no part of the input image is missing in the output. There are problems with that: .IP \(bu If the threedimensional plane defined by the quadrilateral has a visible horizon in the input image, then the above asks \fBpamperspective\fR to include points that cannot ever be part of the output. .IP \(bu If the horizon is not visible, but close to the border of the input image, this may result in very large output files. Consider a picture of a road. If you ask a point close to the horizon to be included, then this point is far away from the viewer. The output will cover many kilometers of road, while \fB--detail\fR perhaps makes a pixel equal to a square centimeter. .LP .LP When working with large files \fBpamperspective\fR's memory usage might be an issue. In order to keep it small, you should minimize each of the following: .IP \(bu The vertical range that the top output line consumes in the input image; .IP \(bu The vertical range that the bottom output line consumes in the input image; .IP \(bu The vertical range from the topmost (with respect to the input image) quadrilateral point to the top (with respect to the output image) output line. .LP For this purpose you can use \fBpamflip\fR before and/or after \fBpamperspective\fR. Example: Instead of .DS L \fBpamperspective 10 0 100 50 0 20 95 100 infile > outfile\fR .DE you can use .DS L \fBpamflip -rotate90 infile | pamperspective 50 0 100 5 0 90 20 100 | pamflip -rotate270 > outfile \fR.DE .SH 2 SEE ALSO .LP \fBnetpbm\fR, \fBpam\fR, \fBpnm\fR, \fBpamcut\fR, \fBpamflip\fR, \fBpnmrotate\fR, \fBpamscale\fR, \fBpnmshear\fR, \fBpnmstitch\fR .SH 2 HISTORY .LP .LP Mark Weyer wrote \fBpamperspective\fR in March 2004. .LP It was new in Netpbm 10.22 (April 2004). .SH 2 AUTHOR .LP This documentation was written by Mark Weyer. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. .SH 2 Table Of Contents .LP .IP \(bu NAME .IP \(bu SYNOPSIS .IP \(bu DESCRIPTION .IP \(bu OPTIONS .IP \(bu HINTS .IP \(bu SEE ALSO .IP \(bu HISTORY .IP \(bu AUTHOR .LP