Bandpass filter default BPF 0.1 4 BRFILTER Bandreject filter default BRF 0.0 50 range:, [0..1] (normalized frequency; 1 = max. freq) , > 0. 1.0=moderate, 10=strong, 100=brickwall These filters modify the current (real) array in the Fourier (frequency) domain. The real data is transformed with a FFT, (becoming complex), filtered, and then transformed back with an IFFT. The lowpass filter smooths out sharp edges, the highpass sharpens them. The bandpass magnifies bumps (wavelengths) of a given size, and the bandreject removes such features. The "SMOOTH" operation is faster for very slight smoothing, but the more powerful LPFILTER can smooth to any degree desired in a single pass. LPF 0.3 1 is a weak filter, LPF 0.05 100 is strong. #fflp #ffhp #ffbp #ffbr FFLPLowpass filter FFHP Highpass filter FFBP Bandpass filter FFBR Bandreject filter These filters operate on complex matrices only. Use LPF, HPF etc. for real data. The data is assumed to be in the frequency domain, and must be subsequently transformed with IFFT. The first (frequency) argument ranges from zero to one (ie, normalized frequency).specifies the strength of the filter, where 1.0 is a weak filter and 100 or larger approaches a brick-wall filter. is the 'quality factor' of a bandpass or band-reject filter, where 1.0 is a gentle filter and 100 or larger is an extremely sharp peak or notch filter. #fft #ifft FFT, IFFT Forward or Inverse (Complex) Fast Fourier Transforms These functions operate on a complex matrix. The data is trans- formed in place, leaving the complex result on the stack. #+ #- #* #/ #^ #pow + - * / ^ POW These operators add, subtract, multiply, divide, or raise to a power each element of the current heightfield. For instance, * 3.14 would multiply each element in the current matrix by the value 3.14. POW may be used a synonym for ^. Example: POW 3.0 converts rolling hills into sharp mountains. #sin #asin #tan #atan SIN ASIN TAN ATAN These operators perform the respective trigonometric function on the current matrix. Input to ASIN is clamped to [-1..1]. #abs ABS Take the absolute value of each matrix element. #log LOG Take the natural logarithm of the input matrix. The log of zero or negative values is set to zero. #diff DIFF Take the differential (local slope) of the matrix. This is called "emboss" in image-processing programs. #dif2 DIF2 Take the second differential (local curvature) of the matrix. The same result is achieved by taking the differential twice. #integrate INT Integrate HF; inverse of DIFF. Needs work to make any useful sense. #invert INVERT For each element of the matrix A, form the result 1/A. (If x is zero, the result is arbitrarily defined as zero.) #negate NEGATE Invert the polarity of a matrix without changing the maximum or minimum values. Peaks become valleys and vice-versa. #normalize NORMALIZE [] Linearly scale the values in the current matrix so that they lie in the range .. . The default range is [0..1]. If (min > max) then the surface will be inverted. Operates on the current matrix in place, without pushing the stack. #nrm2 NRM2 [ ] Multiply each value in the current matrix so that the maximum value becomes . The default max 1.0. If max < 0.0 then the surface will be inverted. Operates on the current matrix in place, without pushing the stack. #zedge ZEDGE [ ] Default: ZEDGE 0.5 1.0 Set the edges of the HF to zero. specifies the fractional distance from the center to the edge to start reducing amplitude. can be from 0.0 to 1.0. sets the smoothing function exponent. Range is anything > 0.0; 1.0 is normally adequate. #equalize EQUALIZE [ ] Make a histogram equalized version of the current matrix, such that there is an equal number of matrix values in each bin. The number of bins used is specified in the variable HISTBINS, default is 1000. The optional 'frac' argument is a real number where 1.0 is complete equalization and 0.0 is no change. Frac can also be less than zero or greater than one, although the results in that case can be hard to predict (the default is 1.0). #hshift HSHIFT [ ] Adds a constant to the matrix such that the most-represented elevation value (usually near 0.5 in a default "gforge" matrix) is shifted to (default = 0.0). This function involves a histogram, using HISTBINS bins for the calculation. #rhist RHISTOGRAM Calculate a radial histogram of values based on an inscribed circle with radius of 1/2 the smaller dimension of the matrix. Mostly useful after (zero swap cjoin fft cmag peak log) Creates a (2xn) matrix with the two columns being radius and corresponding histogram values. Similar to the NIH ImageJ 'Radial Profile' plugin. Save in .OCT format and load file as CSV into Excel or other plot program. #rescale RESCALE Resize the matrix to the specified x and y dimensions. The scaling operation uses bilinear interpolation. The SMOOTH operation should be performed afterwards to remove the interpolation edges. #half HALF Cut x and y dimensions in half, averaging each block of 4 pixels. RESCALE is more general, but that is a simple (sub)sampling operation which is not optimal when decreasing resolution. #double DOUBLE Double the size of the matrix using a modified-midpoint-displacement algorithm (aka Fractint 'plasma') to do fractal interpolation between points. Behavior depends on tiling mode; if tiling is turned off, the new size will be one less than exactly double. Resolution may be re-doubled as many times as you like. specifies the interpolation roughness scale normalized to each local pixel; the default is DOUBLE 0.5 0.0 which will leave the flat areas flat. specifies roughness everywhere: try DOUBLE 0.0 1.0 for added texture even in flat areas. DOUBLE 0 0 is equivalent to RESCALE 2x 2y followed by SMOOTH. #smooth SMOOTH Smooth the matrix by averaging each element with nearest neighbors. argument specifies amount: 0.0 = no smoothing, 1.0 = element is replaced by average of neighbors. may also be less than zero or greater than one; note that this makes surfaces more rough. (Often the smoothest effect is achieved by frac=0.5 ) SMOOTH will behave differently at the edges depending on the setting of the "tile_mode" variable. With ON or AUTO, smoothed heightfields which were tilable will remain so, and in fact edge discontinuities will be reduced. If edge artifacts show up in this mode, your heightfield has a discontinuity across the edge; set tile_mode to OFF. See also: NSMOOTH for many sequential "smooth" operations all-in-one. #joinx #joiny JOINX JOINY Combine the top two HFs X and Y into a single HF by stacking horizontally (joinx) or vertically (joiny). #clip CLIP CLIP Cut out a sub-matrix of the specified dimension from the current HF. and are the x,y offset from (0,0) (top left corner). CLIP 60 40 cuts out a 60x40 matrix starting from (0,0) CLIP 60 40 15 12 cuts out a 60x40 matrix starting from (15,12) #floor #ceiling FLOOR Clip all values less than to equal . CEIL Clip all values greater than to equal . #discrete DISC Discretize HF to have only different levels. Saving your file as a GIF and then loading it is equivalent to DISC 256, because the GIF file has only 256 different colors available. #modulus MOD Take the HF modulus , ie, wrap around at + and - . For a smoother but similar effect, prescale the HF and use SIN. #nsmooth NSMOOTH NSMOOTH Smooth the HF times in sucession, while leaving those values less than and greater than unchanged. Good for changing sharp-edged features (eg. imported B/W letters) into smooth slopes. #lslope LSLOPE Average each pixel which has a local slope greater than with its 4 neighbors. Make passes through the HF in all. This will take a very long time on large HFs. Produces cone-shaped features. To find current maximum HF slope, try: dup;diff;l;pop and look at the maximum value of the 'diff' HF on the stack. #lcurve LCURVE Average each pixel which has a local curvature greater than . Make passes through the HF in all. This is the second-order version of LSLOPE, and converges more quickly. The effect is to smooth out the rough parts of the HF. To find the current maximum HF curvature try: dup;dif2;l;pop and look at the maximum value of the 'dif2' HF on the stack. #add #sub #mul #div ADD Result: Y + X SUB Result: Y - X MUL Result: Y * X DIV Result: Y / X (if X(x,y) != 0; 0 otherwise) These operators combine the two HFs on top of the stack using the respective arithmetic operation on an element-by- element basis. Pixels resulting from a divide-by-zero operation are set to zero. Dimensions of the X HF must be equal to or smaller than those of the Y HF. The optional arguments specify the offset of the X HF relative to the Y; the default is 0 0 (no offset). #exp EXP Result: (Y ^ X) Raise each element in the current matrix to the power of the corresponding element of the second matrix on the stack. Dimensions of the X HF must be equal to or smaller than those of the Y HF. The optional arguments specify the offset of the X HF relative to the Y; the default is 0 0 (no offset). #cmag CMAG Take the magnitude of a complex matrix computed as the square root of the sum of the squares of each element. Result is a real matrix. #rmag RMAG Result: sqrt(X*X + Y*Y) Take the square root of the sum of the squares of the top two matrices, ie, the geometric mean or complex magnitude. Dimensions of the X HF must be equal to or smaller than those of the Y HF. The optional arguments specify the offset of the X HF relative to the Y; the default is 0 0 (no offset). #cjoin CJOIN Combine X (real) and Y (imaginary) matrices into a single complex matrix. Dimensions must be equal. #csplit CSPLIT Replace a complex matrix with two real matrices containing the real and imaginary parts of the original. #cswap CSWAP Exchange real and imaginary portions of current matrix. Matrix be complex. #cdiff CDIFF Take x and y slope (differential) of a real matrix and store the result as a complex matrix: real = Diff(x), imag = Diff(y). #cint CINT Take a complex matrix with x slope (real) and y slope (imag) parts, and generate a real matrix by integration. CDIFF followed by CINT should return the same matrix (apart from roundoff error). #cmag CMAG Take the magnitude of a complex matrix: sqrt(Re*Re + Im*Im) Result is a real matrix. #crect #cpolar CPOLAR Convert one representation of a complex matrix into another CRECT CPOLAR converts a complex matrix in rectangular form to a complex matrix in polar form: Re = sqrt(Re*Re + Im*Im); Im = atan2(Im,Re) CRECT performs the inverse operation from polar to rectangular: Re = Re * cos(Im); Im = Re * sin(Im). (Im units are radians) #cwarp CWARP Map Y matrix into new matrix using complex control matrix X. real portion specifies x shift, imaginary = y shift. Matrix is premultiplied by value, 1 unit= full width of matrix Y. #compos #comneg COMPOS Result: greater of (X, Y) COMNEG Result: lesser of (X, Y) Combine two matrices by choosing each element to be the greater or lesser of the two input elements. The result appears as the 'intersection' of the two components. Dimensions of the X HF must be equal to or smaller than those of the Y HF. The optional arguments specify the offset of the X HF relative to the Y; the default is 0 0 (no offset). #bloom BLOOM BLOOM Radially expand (or contract) the Y matrix to a degree based on the value of each point in the X matrix. Positive = radial expansion, negative = radial contraction. If the control matrix is nonzero at , there will be a discontinuity there. If not specified, = =0.5 (center of the matrix). The control value is premultiplied by (default = 1.0) #twist TWIST TWIST Rotate each point in the Y matrix about (xcent,ycent) by an angle specified by the value (radians) of each corresponding point in the X matrix. Positive = counterclockwise. The rotation angle increment is multiplied by (default = 1.0). If not specified, = = 0.5 (center of the matrix). #formats FORMATS HF-Lab reads and writes a number of different data formats: PNG Portable Network Graphics 16-bit greyscale (compressed) GIF Compuserve GIF87a 8-bit greyscale format (compressed) POT Fractint/POV 16-bit greyscale format (compressed) TGA Targa 24-bit color, but only uses 16 bits (POV format) PGM PPM greyscale format: 8-bit binary or 16-bit-equiv. ASCII MAT Matlab 1.0 format: 32-bit binary floating point OCT Octave ASCII format: 7 digit floating point RAW Raw triangle vertices in ASCII format (output only) Note: Avoid using RAW format if possible. Raw files are 41x bigger (!) Use only MAT (or OCT or RAW) formats for floating-point. HF-Lab can only store values in the range [0..1] in the other formats. #name NAME Give the specified name to the top matrix on the stack. Names may be no longer than 14 characters. #clear CLEAR Erases all heightfields from the stack. All data not saved is lost. #set SET Set a system variable to the specified value. Type 'list variables' to see variable names. 'set' by itself lists all variable values. #seed SEED Set the random number seed to be used for the next 'gforge', 'crater', 'random', or 'fillarray' command. If not set before each 'gforge' etc. command, the seed is regenerated based on the system clock. Type 'set' to see the values of the internal variables including 'seed'. If an asterisk '*' is present, you have set that seed value for next use. If not, that was the seed value used previously. #sample SAMPLE Print the elevation of the HF at the point (x,y). If the value specified is less than one, it is taken as a fraction of the total width, else it is taken as the coordinate directly. For example SAM 0.5 0.5 reports the elevation at the center of the matrix. If is not specified it is set to equal . #print PRINT [f|e] [n] Print each elevation value in the HF. If the HF is complex, print as (real, imaginary) pairs. f or e option specifies floating point or exponential notation, for example print 2: 1.00 0.31 0.23 ... or "print e 3" 4.261e-01 1.842e-01 ... Default is "print f 3" Mostly useful for testing, with matrices of very small dimensions. #histogram HIST Print a text-mode histogram of the elements in the current matrix. #tshow TSHOW Default: width=78 height=20 Show a 2D view of matrix in text mode using characters for shading. Very crude; may be useful if you have a slow link to your remote computer or a text-only terminal. Reminiscent of '70s computing. #tic #toc TIC TOC TIC starts an internal timer running. TOC prints out the elapsed time. This may be useful for comparing speeds of computer systems. For example, the command TIC; GFORGE 600; TOC will print out how long your computer takes to fill a 600x600 matrix with random number pairs and compute a complex 2D-FFT. #wait WAIT Pause the specified number of seconds. Useful in a script. #repeat REPEAT repeat the following commands times. For example GFORGE 10; REP 3 GFORGE 10;ADD will leave a matrix on the stack which is the sum of four separate matrices. #xyzzy !? You must be kidding me. #tile? TILE? Report if the current heightfield appears to tile smoothly. #version VERSION Prints the current version of the software. #author AUTHOR HF-Lab was first written by John Beale in January, 1996. I wrote it to enable me to explore ways to generate interesting-appearing surfaces, for eventual viewing in a raytracer (eg, the wonderful freeware POV-Ray program). You may find it useful for generating mountains or other landscapes. This program is available free of charge under the GNU Public License. You may distribute it freely. Type 'HELP WARRANTY' for more details. If you come up with any additions to HF-Lab you like, please let me know. Thanks! John Beale www.bealecorner.com #warranty WARRANTY HeightField-Lab -- Generation and manipulation of heightfields Copyright (C) 1996-2013 John P. Beale 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 2 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Type 'HELP AUTHOR' for more information about the author of HF-Lab. #shader VARIABLE shader: shading model for the 3D image in 'view' function WIRE B/W wireframe view, no shading. HEIGHT image colored according to height SLOPE image colored according to local slope LIGHT shading according to lightsource (most realistic) #tolerance VARIABLE tolerance: value used to distinguish a matrix which can be seamlessly tiled, from one that can't. 0.01 seems to work ok. This has meaning only when variable 'tile_mode' is set to AUTO. (see also) #tile_mode VARIABLE tile_mode: treatment of matrix edge-wraparound. ON consider matrix to be seamlessly tilable OFF consider matrix to have unique edges AUTO attempt to auto-determine tilability of any given matrix by using algorithm. The functions DOUBLE, RESCALE, SMOOTH, CRATER, GAUSS, and RING have two modes of behavior, and which one should be used depends on whether the matrix is seamlessly tilable (e.g. any output of GFORGE) or not (e.g. almost anything else). The auto-detect mode isn't as sensitive as your eye, so if you know the tilability of your matrix, it's better to set tile_mode to ON or OFF rather than the default AUTO. #histbins VARIABLE histbins: number of bins used in histogram equalization. This can be any positive integer greater than one. The default is 1000. See also EQUALIZE. #stacksize VARIABLE stacksize: number of matrices to store on stack. This can be any positive integer greater than one. NOTE!! changing the stack size erases all current contents of the stack. Save anything important first. #nskip VARIABLE nskip: matrix elements to skip in 3D viewing mode Range: any positive integer. If nskip is greater than one, the 3D view will be draw more quickly, but with less detail. #graphmode VARIABLE graphmode: DOS graphics mode (not relevant for X version) 0: 320x200 1: 640x480 2: 800x600 3:1024x768 All graphics modes are 256 color greyscale. #randgauss VARIABLE randgauss: TRUE=gaussian (normal) distrib. FALSE=even (uniform) This relates to the RANDOM matrix generator (see). #v_tile VARIABLE v_tile display tiled HF in 3D view if TRUE, single HF if FALSE #filenum VARIABLE filenum: current number used as suffix on saved filename #appendnum VARIABLE appendnum: TRUE=append the [filenum] to filename before saving FALSE= do not add a number If appendnum=TRUE, then each time "save a.png" is executed, a different filename is written, for example a0000.png, a0001.png ... #sl-min #sl-scale VARIABLE sl-min slope to set black (eg, minimum slope) sl-scale range of slopes scaling from black-white These variables control the slope-shading option in the 3D view mode. They apply only for the shading by slope (S3) option. (default is lightsource shading)