ImageStack Operation Listing

Operations available are: -abs -add -adjoin -affinewarp -align -alignframes -assemblehdr -bidirectionalsimilarity -bilateral -bilateralsharpen -chromablur -circularfilter -clamp -colorconvert -colormatrix -complexconjugate -complexdivide -compleximag -complexmagnitude -complexmultiply -complexphase -complexreal -composite -convolve -createtmp -crop -daubechies -dct -deconvolve -deinterleave -demosaic -denan -dimensionreduction -dimensions -display -divide -downsample -dup -envelope -equalize -eval -evalchannels -exp -fastblur -fft -fftconvolve -fftpoisson -flip -fprintf -frametiles -gamma -gaussianblur -gausstransform -gradient -gradmag -haar -heal -help -histogram -histogrammatch -hotpixelsuppression -ifft -inpaint -integrate -interleave -inversedaubechies -inversehaar -jointbilateral -kernelestimation -kmeans -lahbpcg -lanczosblur -lffocalstack -lfpoint -lfwarp -load -loadarray -loadblock -loadchannels -loadframes -loadpanorama -locallaplacian -localmaxima -log -loop -max -medianfilter -min -mod -multiply -nlmeans -nlmeans3d -noise -normalize -offset -opticalflow -opticalflowwarp -panoramabackground -paste -patchmatch -patchpca -patchpca3d -pause -pca -percentilefilter -plot -plugin -poisson -pop -printf -pull -push -quantize -realcomplex -receive -rectfilter -resample -reshape -rotate -save -savearray -saveblock -savechannels -saveframes -scale -send -shuffle -sinugram -sort -stash -statistics -subsample -subtract -threshold -tile -tileframes -time -translate -transpose -upsample -warp -wls

abs

-abs takes the absolute value of the current image.

Usage: ImageStack -load a.tga -load b.tga -subtract -abs -save diff.tga

add

-add adds the second image in the stack to the top image in the stack.

Usage: ImageStack -load a.tga -load b.tga -add -save out.tga.

adjoin

-adjoin takes 'x', 'y', 't', or 'c' as the argument, and joins the top two images along that dimension. The images must match in the other dimensions.

Usage: ImageStack -load a.tga -load b.tga -adjoin x -save ab.tga

affinewarp

-affinewarp takes a 2x3 matrix in row major order, and performs that affine warp on the image.

Usage: ImageStack -load a.jpg -affinewarp 0.9 0.1 0 0.1 0.9 0 -save out.jpg

align

-align warps the top image on the stack to match the second image on the stack. align takes one argument, which must be "translate", "similarity", "affine", "perspective", or "rigid" and constrains the warp to be of that type.

Usage: ImageStack -load a.jpg -load b.jpg -align similarity \ -add -save ab.jpg

alignframes

assemblehdr

-assemblehdr takes a volume in which each frame is a linear luminance image taken at a different exposure, and compiles them all into a single HDR image, gracefully handling oversaturated regions.

If exposure values are known, they can be given in increasing frame order. Otherwise, assemblehdr attempts to discover the exposure ratios itself, which may fail if there are very few pixels that are properly imaged in multiple frames. For best results, load the frames in either increasing or decreasing exposure order.

Usage: ImageStack -loadframes input*.jpg -gamma 0.45 -assemblehdr -save out.exr or ImageStack -loadframes input*.jpg -gamma 0.45 -assemblehdr 1.0 0.5 0.1 -save output.exr

bidirectionalsimilarity

-bidirectionalsimilarity reconstructs the top image on the stack using patches from the second image on the stack, by enforcing coherence (every patch in the output must look like a patch from the input) and completeness (every patch from the input must be represented somewhere in the output). The first argument is a number between zero and one, which trades off between favoring coherence only (at zero), and completeness only (at one). It defaults to 0.5. The second arguments specifies the number of iterations that should be performed, and defaults to five. Bidirectional similarity uses patchmatch as the underlying nearest-neighbour-field algorithm, and the third argument specifies how many iterations of patchmatch should be performed each time it is run. This also defaults to five.

This is an implementation of the paper "Summarizing visual data using bidirectional similarity" by Simakov et al. from CVPR 2008.

Usage: ImageStack -load source.jpg -load target.jpg -bidirectional 0.5 -display

bilateral

-bilateral blurs the top image in the second without crossing boundaries. It takes up to five arguments: the color standard deviation of the filter, the standard deviations in width, height, and frames, and the method to use (see -gausstransform for a description of the methods). If the method is omitted it automatically chooses an appropriate one. Temporal standard deviation defaults to zero, and standard deviation in height defaults to the same as the standard deviation in width

Usage: ImageStack -load im.jpg -bilateral 0.1 4

bilateralsharpen

-bilateralsharpen sharpens using a bilateral filter to avoid ringing. The three arguments are the spatial and color standard deviations, and the sharpness. A sharpness of zero has no effect; a sharpness of 1 is significant.

Usage: ImageStack -load input.jpg -bilateralsharpen 1.0 0.2 1 -save sharp.jpg

chromablur

-chromablur blurs an image in the chrominance channels only. It is a good way of getting rid of chroma noise without apparently blurring the image. The two arguments are the standard deviation in space and color of the bilateral filter. Usage: ImageStack -load input.jpg -chromablur 2 -save output.png

circularfilter

-circularfilter convolves the image with a uniform circular kernel. It is a good approximate to out of focus blur. The sole argument is the radius of the filter.

Usage: ImageStack -load in.jpg -circularfilter 10 -save out.jpg

clamp

-clamp restricts the image to be between the given minimum and maximum by saturating values outside that range. If given no arguments it defaults to clamping between zero and one.

Usage: ImageStack -load a.exr -clamp 0 1 -save a.tga

colorconvert

-colorconvert converts from one colorspace to another. It is called with two arguments representing these colorspaces.

Allowable colorspaces are rgb, yuv, hsv, xyz, lab and y (luminance alone). grayscale, gray, and luminance are synonyms for y, and hsb and hsl are synonyms for hsv.

Usage: ImageStack -load a.tga -colorconvert rgb hsv -scale 0.1 1 1 -colorconvert hsv rgb -save out.tga

colormatrix

-colormatrix treats each pixel as a vector over its channels and multiplies the vector by the given matrix. The matrix size and shape is deduced from the number of arguments. The matrix is specified in column major order.

Converting rgb to grayscale: ImageStack -load color.tga -colormatrix 1 1 1 -scale 0.33333 -save gray.tga

Making orange noise: ImageStack -push 100 100 1 1 -noise -colormatrix 1 0.3 0 -save noise.tga

Making noise that varies between orange and blue: ImageStack -push 100 100 1 2 -noise -colormatrix 1 0.3 0 0 0 1 -save noise.tga

complexconjugate

-complexconjugate takes a "complex" image, in which the even channels represent the real component and the odd channels represent the imaginary component, and produces an image containing the complex conjugate

Usage: ImageStack -load a.png -fftreal -complexconjugate -display

complexdivide

-complexdivide divides the top image in the stack by the second image in the stack, using 2 "complex" images as its input - a "complex" image is one where channel 2*n is the real part of the nth channel and channel 2*n + 1 is the imaginary part of the nth channel. Using zero arguments results in a straight division (a + bi) / (c + di). Using one argument results in a conjugate division (a - bi) / (c + di).

Usage: ImageStack -load a.tga -load b.tga -complexdivide -save out.tga.

compleximag

-compleximag takes a "complex" image, in which the even channels represent the real component and the odd channels represent the imaginary component, and produces an image containing only the imaginary channels.

Usage: ImageStack -load a.png -fftreal -compleximag -display

complexmagnitude

-complexmagnitude takes a "complex" image, in which the even channels represent the real component and the odd channels represent the imaginary component, and produces an image containing the complex magnitude

Usage: ImageStack -load a.png -fftreal -complexmagnitude -display

complexmultiply

-complexmultiply multiplies the top image in the stack by the second image in the stack, using 2 "complex" images as its input - a "complex" image is one where channel 2*n is the real part of the nth channel and channel 2*n + 1 is the imaginary part of the nth channel. Using zero arguments results in a straight multiplication (a + bi) * (c + di), using one argument results in a conjugate multiplication (a - bi) * (c + di).

Usage: ImageStack -load a.tga -load b.tga -complexmultiply -save out.tga.

complexphase

-complexphase takes a "complex" image, in which the even channels represent the real component and the odd channels represent the imaginary component, and produces an image containing the complex phase

Usage: ImageStack -load a.png -fftreal -complexphase -display

complexreal

-complexreal takes a "complex" image, in which the even channels represent the real component and the odd channels represent the imaginary component, and produces an image containing only the real channels.

Usage: ImageStack -load a.png -fftreal -complexreal -display

composite

-composite composites the top image in the stack over the next image in the stack, using the last channel in the top image in the stack as alpha. If the top image in the stack has only one channel, it interprets this as a mask, and composites the second image in the stack over the third image in the stack using that mask.

Usage: ImageStack -load a.jpg -load b.jpg -load mask.png -composite ImageStack -load a.jpg -load b.jpg -evalchannels [0] [1] [2] \ "x>width/2" -composite -display

convolve

-convolve takes a width, height, and frames and a single-channel 3D kernel specified across the rows, then down the columns, then over time, and convolves the current image by that matrix independently in each channel.

With no numeric arguments, -convolve will use the next image on the stack as the filter.

Boundary conditions can be specified by appending the argument "zero", "homogeneous", "clamp", or "wrap", which result in the respective assumptions: the image is zero outside the boundary; the image is weighted with weight one inside the boundary, and weight zero outside the boundary; the image values outside the boundary clamp to the nearest defined image value (Neumann); and the image wraps outside the boundary.

Convolution by multi-channel filters is poorly defined, because it requires a vector-vector multiplication between filter values and image values. By specifying a final argument of "inner", "outer", or "elementwise", the multiplication used is correspondingly the inner product (or matrix product if the image and kernel have a differing number of frames); the outer product; or an elementwise product. If the kernel has k channels and the image has m channels, "inner" produces an image with max(m/k, k/m) channels, "outer" produces an image with m*k channels, and "elementwise" requires that m==k and produces an image with the same number of channels. The default method is "outer".

Taking a horizontal gradient with zero boundary condition: ImageStack -load a.tga -convolve 2 1 1 -1 1 zero -save dx.tga Convolving by a bank of filters: ImageStack -load bank.tmp -load a.tga -convolve homogeneous outer

createtmp

-createtmp creates a zero filled floating point .tmp file of the specified dimensions. It can be used to create tmp files larger than can fit in memory. The five arguments are the filename, width, height, frames and channels. If only four arguments are specified, frames is assumed to be one.

The following example creates a giant volume, and fills some of it with noise: ImageStack -createtmp volume.tmp 1024 1024 1024 1 \ -push 256 256 256 1 -noise \ -saveblock volume.tmp 512 512 512 0

crop

-crop takes either zero, two, four, or six arguments. The first half of the arguments are either minimum t, minimum x and y, or all three in the order x, y, t. The second half of the arguments are correspondingly either number of frames, width and height, or all three in the order width, height, frames. You may crop outside the bounds of the original image. Values there are assumed to be black. If no argument are given, ImageStack guesses how much to crop by trimming rows and columns that are all the same color as the top left pixel.

Usage: ImageStack -loadframes f*.tga -crop 10 1 -save frame10.tga ImageStack -load a.tga -crop 100 100 200 200 -save cropped.tga ImageStack -loadframes f*.tga -crop 100 100 10 200 200 1 -save frame10cropped.tga

daubechies

-daubechies performs the standard 2D daubechies 4 wavelet transform of an image. The image size must be a power of two.

Usage: ImageStack -load in.jpg -daubechies -save out.jpg

dct

-dct performs a real discrete cosine transform on the current image, over the dimensions given in the argument. If no arguments are given, every dimension is transformed.

Usage: ImageStack -load a.png -dct xy -save freq.png

deconvolve

-deconvolution will deconvolve an image with the kernel in the stack. This operation takes the name of the deconvolution method as a single argument, plus any optional arguments that the method may require. Currently supported are "cho" (Cho and Lee, 2009), "shan" (Shan et al, 2008), and "levin" - the simpler method with a Gaussian prior on gradients describe in (Levin 2007). The method "levin" takes an additional argument to specify the weight given to the prior.

Usage: ImageStack -load blurred -load kernel -deconvolve cho

deinterleave

-deinterleave collects every nth frame, column, and/or row of the image and tiles the resulting collections. When given two arguments it operates on columns and rows. When given three arguments, it operates on all columns, rows, and frames.

Usage: ImageStack -load lf.exr -deinterleave 16 16 -save lftranspose.exr

demosaic

-demosaic demosaics a raw bayer mosaiced image camera. It should be a one channel image. The algorithm used is adaptive color plane interpolation (ACPI). Demosaic optionally takes two or three arguments. Two arguments specify an offset of the standard bayer pattern in x and y. The presence of a third argument indicates that auto-white-balancing should be performed.

Usage: ImageStack -load photo.dng -demosaic -save out.png ImageStack -load raw.yuv -demosaic 0 1 awb -save out.png

denan

-denan replaces all NaN values in the current image with its argument, which defaults to zero.

Usage: ImageStack -load in.jpg -eval "1/val" -denan -save out.jpg

dimensionreduction

-dimensionreduction takes a dimensionality and projects all points on the image onto a linear subspace of best fit with that number of dimensions. It is useful if you know an image should be low dimensional (eg a sunset is mostly shades or red), and components orthogonal to that dimension are unwanted (eg chromatic abberation).

Usage: ImageStack -load sunset.jpg -dimensionreduction 2 -save fixed.jpg

dimensions

-dimensions prints the size of the current image.

Usage: ImageStack -load a.tga -dimensions

display

-display opens a window and displays the current image. Subsequent displays will use the same window. The presence of an optional second argument indicates that the window should be fullscreen.

Usage: ImageStack -load a.tga -loop 100 --display --gaussianblur 2

divide

-divide divides the top image in the stack by the second image in the stack.

Usage: ImageStack -load a.tga -load b.tga -divide -save out.tga.

downsample

-downsample divides the width, height, and frames of the current image by the given integer arguments. It averages rectangles to get the new values.

-downsample x y is interpreted as -downsample x y 1 -downsample x is interpreted as -downsample x x 1 -downsample is interpreted as -downsample 2 2 1

Usage: ImageStack -load a.tga -downsample 3 2 -save b.tga

dup

-dup duplicates an image and pushes it on the stack. Given no argument it duplicates the top image in the stack. Given a numeric argument it duplicates that image from down the stack. Given a string argument it duplicates an image that was stashed with -stash using that name

Usage: ImageStack -load a.tga -dup -scale 0.5 -save a_small.tga -pop -scale 2 -save a_big.tga

envelope

-envelope computes a lower or upper envelope of the input, which is smooth, and less than (or greater than) the input. The first argument should be "lower" or "upper". The second argument is the desired smoothness, which should be greater than zero and strictly less than one. The last argument is the degree of edge preserving. If zero, the output will be smooth everywhere. Larger values produce output that is permitted to have edges where the input does, in a manner similar to a bilateral filter.

Usage: ImageStack -load a.jpg -envelope upper 0.5 1 -display

To locally maximize contrast: ImageStack -load a.jpg -dup -scale 1.1 -envelope lower 0.9 1 -pull 1 -subtract -envelope upper 0.9 1 -offset 1 -pull 1 -pull 2 -add -divide -display

equalize

-equalize flattens out the histogram of an image, while preserving ordering between pixel brightnesses. It does this independently in each channel. When given no arguments, it produces an image with values between zero and one. With one argument, it produces values between zero and that argument. With two arguments, it produces values between the two arguments. The brightest pixel(s) will always map to the upper bound and the dimmest to the lower bound.

Usage: ImageStack -load a.tga -equalize 0.2 0.8 -save out.tga

eval

-eval takes a simple expression and evaluates it, writing the result to the current image.

Variables: x the x coordinate, measured from 0 to width - 1 y the y coordinate, measured from 0 to height - 1 t the t coordinate, measured from 0 to frames - 1 c the current channel val the image value at the current x, y, t, c

Constants: e 2.71828183 pi 3.14159265

Uniforms: frames the number of frames width the image width height the image height channels the number of channels Unary Operations: - unary negation

Binary Operations: + addition - subtraction % modulo * multiplication / division ^ exponentiation > greater than < less than >= greater than or equal to <= less than or equal to == equal to != not equal to

Other Operations: a ? b : c if a then b else c [c] sample the image here on channel c [x, y] sample the image with a 3 lobed lanczos filter at X, Y at this channel [x, y, t] sample the image with a 3 lobed lanczos filter at X, Y, T at this channel

Functions: log(x) the natural log of x exp(x) e to the power of x sin(x) the sine of x cos(x) the cosine of x tan(x) the tangent of x asin(x) the inverse sine of x acos(x) the inverse cosine of x atan(x) the inverse tangent of x atan2(y, x) the angle of the vector x, y above horizontal abs(x) the absolute value of x floor(x) the value of x rounded to the nearest smaller integer ceil(x) the value of x rounded to the nearest larger integer round(x) the value of x rounded to the nearest integer mean() the mean value of the image across all channels mean(c) the mean value of the image in channel c sum() the sum of the image across all channels sum(c) the sum of the image in channel c max() the maximum of the image across all channels max(c) the maximum of the image in channel c min() the minimum of the image across all channels min(c) the minimum of the image in channel c stddev() the standard deviation of the image across all channels stddev(c) the standard deviation of the image in channel c variance() the variance of the image across all channels variance(c) the variance of the image in channel c skew() the skew of the image across all channels skew(c) the skew of the image in channel c kurtosis() the kurtosis of the image across all channels kurtosis(c) the kurtosis of the image in channel c covariance(c1, c2) the covariance between channels c1 and c2

To add more functionality, see Parser.cpp in the source

Usage: ImageStack -push 128 128 128 1 -eval "(x*y*t)^0.5" -save out.tga

evalchannels

-evalchannels takes some expressions and evaluates them, writing the results to an image with that many channels.

Variables: x the x coordinate, measured from 0 to width - 1 y the y coordinate, measured from 0 to height - 1 t the t coordinate, measured from 0 to frames - 1 c the current channel val the image value at the current x, y, t, c

Constants: e 2.71828183 pi 3.14159265

Uniforms: frames the number of frames width the image width height the image height channels the number of channels Unary Operations: - unary negation

Binary Operations: + addition - subtraction % modulo * multiplication / division ^ exponentiation > greater than < less than >= greater than or equal to <= less than or equal to == equal to != not equal to

Other Operations: a ? b : c if a then b else c [c] sample the image here on channel c [x, y] sample the image with a 3 lobed lanczos filter at X, Y at this channel [x, y, t] sample the image with a 3 lobed lanczos filter at X, Y, T at this channel

Functions: log(x) the natural log of x exp(x) e to the power of x sin(x) the sine of x cos(x) the cosine of x tan(x) the tangent of x asin(x) the inverse sine of x acos(x) the inverse cosine of x atan(x) the inverse tangent of x atan2(y, x) the angle of the vector x, y above horizontal abs(x) the absolute value of x floor(x) the value of x rounded to the nearest smaller integer ceil(x) the value of x rounded to the nearest larger integer round(x) the value of x rounded to the nearest integer mean() the mean value of the image across all channels mean(c) the mean value of the image in channel c sum() the sum of the image across all channels sum(c) the sum of the image in channel c max() the maximum of the image across all channels max(c) the maximum of the image in channel c min() the minimum of the image across all channels min(c) the minimum of the image in channel c stddev() the standard deviation of the image across all channels stddev(c) the standard deviation of the image in channel c variance() the variance of the image across all channels variance(c) the variance of the image in channel c skew() the skew of the image across all channels skew(c) the skew of the image in channel c kurtosis() the kurtosis of the image across all channels kurtosis(c) the kurtosis of the image in channel c covariance(c1, c2) the covariance between channels c1 and c2

To add more functionality, see Parser.cpp in the source

Usage: ImageStack -push 128 128 128 1 -evalchannels "[0]*2" "[1]*2 + [0]" -save out.tga

exp

With no arguments -exp calculates e to the current image. With one argument it calculates that argument to the power of the current image.

Usage: ImageStack -load a.tga -log -load b.tga -log -add -exp -save product.tga.

fastblur

-fastblur takes a floating point frames, width, and height, and performs a fast approximate gaussian blur with those standard deviations using the IIR method of van Vliet et al. If given only two arguments, it performs a blur in x and y only. If given one argument, it performs the blur in x and y with filter width the same as height.

Usage: ImageStack -load in.jpg -fastblur 5 -save blurry.jpg

fft

-fft performs a fast dft on the current image, whose values are interpreted as complex. The input is an image with 2*c channels, where channel 2*i is the real part of the i'th channel, and channel 2*i+1 is the imaginary part of the i'th channel. The output image is laid out the same way.

Usage: ImageStack -load a.tmp -fftcomplex -save freq.tmp

fftconvolve

-fftconvolve performs convolution in Fourier space. It is much faster than -convolve for large kernels. The two arguments are the boundary condition (zero, clamp, wrap, homogeneous) and the vector-vector multiplication used (inner, outer, elementwise). The defaults are wrap and outer respectively. See -convolve for a description of each option.

Usage: ImageStack -load filter.tmp -load im.jpg -fftconvolve zero inner

fftpoisson

-fftpoisson computes an image from a gradient field in the same way as -poisson. It interprets the top image on the stack as the y gradient, and the next image as the x gradient. If a single argument is given, it uses that as a weight, and interprets the third image on the stack as a rough target output. The output of this operation will adhere to the target proportionally to the given weight.

Usage: ImageStack -load gx.tmp -load gy.tmp -fftpoisson -display

flip

-flip takes 'x', 'y', or 't' as the argument and flips the current image along that dimension.

Usage: ImageStack -load a.tga -flip x -save reversed.tga

fprintf

-fprintf evaluates and prints its arguments, appending them to the file specified by the first argument, using the second argument as a format string. The remaining arguments are all evaluated as floats, so use %%d, %%i, and other non-float formats with caution.

Usage: ImageStack -load foo.jpg -fprintf results.txt "Mean = %%f" "mean()"

frametiles

-frametiles takes a volume where each frame is a grid and breaks each frame into multiple frames, one per grid element. The two arguments specify the grid size. This operation is the inverse of tileframes.

Usage: ImageStack -loadframes sheet*.tif -frametiles 5 5 -saveframes frame%d.tif

gamma

-gamma raise the current image to a power. It can either be called with a single argument, or with one argument per image channel. Usage: ImageStack -load a.tga -gamma 0.5 34 2 -save b.tga

gaussianblur

-gaussianblur takes a floating point width, height, and frames, and performs a gaussian blur with those standard deviations. The blur is performed out to three standard deviations. If given only two arguments, it performs a blur in x and y only. If given one argument, it performs the blur in x and y with filter width the same as height.

Usage: ImageStack -load in.jpg -gaussianblur 5 -save blurry.jpg

gausstransform

-gausstransform evaluates a weighted sum of Gaussians at a discrete set of positions. The positions are given by the top image on the stack, the locations of the Gaussians are given by the second image, and the weights of the Gaussians are given by the third. There are several ways to accelerate a Gauss transform, therefore -gausstransform takes one argument to indicate the method to use, and then one argument per channel in the second image in the stack to indicate the standard deviation of the desired Gaussian in that dimension. Methods available are: exact (slow!); grid (the bilateral grid of Paris et al.); permutohedral (the permutohedral lattice of Adams et al.); and gkdtree (the gaussian kdtree of Adams et al.). If only one argument is given, the standard deviations used are all one. If two arguments are given, the standard deviation is the same in each dimension.

Usage: ImageStack -load pics/dog1.jpg -evalchannels [0] [1] [2] 1 \ -dup -evalchannels x y [0] [1] [2] -dup \ -gausstransform permutohedral 4 4 0.1 0.1 0.1 \ -evalchannels [0]/[3] [1]/[3] [2]/[3] \ -save bilateral_filtered_dog.jpg

gradient

-gradient takes the backward differences in the dimension specified by the argument. Values outside the image are assumed to be zero, so the first row, or column, or frame, will not change, effectively storing the initial value to make later integration easy. Multiple arguments can be given to differentiate with respect to multiple dimensions in order (although the order does not matter).

Warning: Don't expect to differentiate more than twice and be able to get back the image by integrating. Numerical errors will dominate.

Usage: ImageStack -load a.tga -gradient x y -save out.tga

gradmag

-gradmag computes the square gradient magnitude at each pixel in x and y. Temporal gradients are ignored. The gradient is estimated using backward differences, and the image is assumed to be zero outside its bounds.

Usage: ImageStack -load input.jpg -gradmag -save out.jpg

haar

-haar performs the standard 2D haar transform of an image. The image size must be a power of two. If given an integer argument k, it only recurses k times, and the image size must be a multiple of 2^k.

Usage: ImageStack -load in.jpg -haar 1 -save out.jpg

heal

-heal takes an image and a mask, and reconstructs the portion of the image where the mask is high using patches from the rest of the image. It uses the patchmatch algorithm for acceleration. The arguments include the number of iterations to run per scale, and the number of iterations of patchmatch to run. Both default to five.

Usage: ImageStack -load mask.png -load image.jpg -heal -display

help

ImageStack is a stack language for manipulating images. It is appropriate for use on the command line and in scripts. Internally, all data is stored as 32 bit floating point, so ImageStack is good for high dynamic range data. ImageStack is also useful for low dynamic range data, which it treats as values between 0 and 1.

-help provides help on a given operation. Usage: ImageStack -help scale

Operations available are: -abs -add -adjoin -affinewarp -align -alignframes -assemblehdr -bidirectionalsimilarity -bilateral -bilateralsharpen -chromablur -circularfilter -clamp -colorconvert -colormatrix -complexconjugate -complexdivide -compleximag -complexmagnitude -complexmultiply -complexphase -complexreal -composite -convolve -createtmp -crop -daubechies -dct -deconvolve -deinterleave -demosaic -denan -dimensionreduction -dimensions -display -divide -downsample -dup -envelope -equalize -eval -evalchannels -exp -fastblur -fft -fftconvolve -fftpoisson -flip -fprintf -frametiles -gamma -gaussianblur -gausstransform -gradient -gradmag -haar -heal -help -histogram -histogrammatch -hotpixelsuppression -ifft -inpaint -integrate -interleave -inversedaubechies -inversehaar -jointbilateral -kernelestimation -kmeans -lahbpcg -lanczosblur -lffocalstack -lfpoint -lfwarp -load -loadarray -loadblock -loadchannels -loadframes -loadpanorama -locallaplacian -localmaxima -log -loop -max -medianfilter -min -mod -multiply -nlmeans -nlmeans3d -noise -normalize -offset -opticalflow -opticalflowwarp -panoramabackground -paste -patchmatch -patchpca -patchpca3d -pause -pca -percentilefilter -plot -plugin -poisson -pop -printf -pull -push -quantize -realcomplex -receive -rectfilter -resample -reshape -rotate -save -savearray -saveblock -savechannels -saveframes -scale -send -shuffle -sinugram -sort -stash -statistics -subsample -subtract -threshold -tile -tileframes -time -translate -transpose -upsample -warp -wls

histogram

-histogram computes a per-channel histogram of the current image. The first optional argument specifies the number of buckets in the histogram. If this is not given it defaults to 256. The second and third arguments indicate the range of data to expect. These default to 0 and 1.Usage: ImageStack -load a.tga -histogram -normalize -plot 256 256 3 -display

histogrammatch

-histogrammatch alters the histogram of the current image to match that of the second image, while preserving ordering. Performing any monotonic operation to an image, and then histogram matching it to its original should revert it to its original.

Usage: ImageStack -load a.tga -load b.tga -histogrammatch -save ba.tga

hotpixelsuppression

-hotpixelsuppression removes salt-and-pepper noise from an image by constraining each pixel to be within the bounds of its four neighbors

Usage: ImageStack -load noisy.jpg -hotpixelsuppression -save denoised.jpg

ifft

-ifft performs an inverse dft on the current image, whose values are complex. The input and output are images with 2*c channels, where channel 2*i is the real part of the i'th channel, and channel 2*i+1 is the imaginary part of the i'th channel.

Usage: ImageStack -load a.tga -fftcomplex -save freq.tga

inpaint

-inpaint takes the image on the top of the stack, and a one channel mask of the same size second on the stack, and diffuses areas of the image where the mask is high into areas of the image where the mask is low. Image pixels with mask of 1 are unchanged.

Usage: ImageStack -push 1 640 480 1 -eval "(X > 0.5)*(X < 0.6)" -load in.jpg -inpaint -save out.jpg

integrate

-integrate computes partial sums along the given dimension. It is the of the -gradient operator. Multiply dimensions can be given as arguments, for example -integrate x y will produce a summed area table of an image. Allowed dimensions are x, y, or t.

Warning: Don't expect to integrate more than twice and be able to get back the image by differentiating. Numerical errors will dominate.

Usage: ImageStack -load a.tga -gradient x y -integrate y x -save a.tga

interleave

-interleave divides the image into n equally sized volumes and interleaves them. When given two arguments it operates on columns and rows. When given three arguments, it operates on columns, rows, and frames.

Usage: ImageStack -load deck.exr -interleave 2 -save shuffled.exr

inversedaubechies

-inversedaubechies performs the standard 2D daubechies 4 wavelet transform of an image. The image size must be a power of two.

Usage: ImageStack -load in.jpg -inversedaubechies -save out.jpg

inversehaar

-inversehaar inverts the haar transformation with the same argument. See -help haar for detail.

jointbilateral

-jointbilateral blurs the top image in the second without crossing boundaries in the second image in the stack. It takes up to five arguments: the color standard deviation of the filter, the standard deviations in width, height, and frames, and the method to use (see -gausstransform for a description of the methods). If the method is omitted it automatically chooses an appropriate one. Temporal standard deviation defaults to zero, and standard deviation in height defaults to the same as the standard deviation in width

Usage: ImageStack -load ref.jpg -load im.jpg -jointbilateral 0.1 4

kernelestimation

-kernelestimation will compute an estimated blur kernel from a blurry image using the algorithm described in Cho and Lee, 2009. It takes an optional argument that specifies the kernel size. The default is 25. Usage: ImageStack -load blurred -kernelestimation 25 -deconvolve cho

kmeans

-kmeans clusters the image into a number of clusters given by the single integer argument.

Usage: ImageStack -load in.jpg -kmeans 3 -save out.jpg

lahbpcg

-lahbpcg takes six images from the stack and treats them as a target output, x gradient, and y gradient, and then the respective weights for each term. The weights may be single-channel or have the same number of channels as the target images. It then attempts to solve for the image which best achieves that target ouput and those target gradients in the weighted-least-squares sense using a preconditioned weighted least squares solver. This technique is useful for a variety of problems with constraints expressed in the gradient domain, including Poisson solves, making a sparse labelling dense, and other gradient-domain techniques. The problem formulation is from Pravin Bhat's "GradientShop", and the preconditioner is the Locally Adapted Hierarchical Basis Preconditioner described by Richard Szeliski.

This operator takes two arguments. The first specifies the maximum number of iterations, and the second specifies the error required for convergence

The following example takes a sparse labelling of an image im.jpg, and expands it to be dense in a manner that respects the boundaries of the image. The target image is the labelling, with weights indicating where it is defined. The target gradients are zero, with weights inversely proportional to gradient strength in the original image. Usage: ImageStack -load sparse_labels.tmp \ -push -dup \ -load sparse_weights.tmp \ -load im.jpg -gradient x -colorconvert rgb gray \ -eval "1/(100*val^2+0.001)" \ -load im.jpg -gradient y -colorconvert rgb gray \ -eval "1/(100*val^2+0.001)" \ -lahbpcg 5 0.001 -save out.png

lanczosblur

-lanczosblur convolves the current image by a three lobed lanczos filter. A lanczos filter is a kind of windowed sinc. The three arguments are filter width, height, and frames. If two arguments are given, frames is assumed to be one. If one argument is given, it is interpreted as both width and height.

Usage: ImageStack -load big.jpg -lanczosblur 2 -subsample 2 2 0 0 -save small.jpg

lffocalstack

-lffocalstack turns a 4d light field into a 3d focal stack. The five arguments are the lenslet width, height, the minimum alpha, the maximum alpha, and the step size between adjacent depths (alpha is slope in line space).

Usage: ImageStack -load lf.exr -lffocalstack 16 16 -1 1 0.1 -display

lfpoint

-lfpoint colors a single 3d point white in the given light field. The five arguments are the light field u, v, resolution, and then the x, y, and z coordinates of the point. x and y should be in the range [0, 1], while z is disparity. z = 0 will be at the focal plane.

Usage: ImageStack -load lf.exr -lfpoint 16 16 0.5 0.5 0.1 -save newlf.exr

lfwarp

-lfwarp treats the top image of the stack as indices (within [0, 1]) into the lightfield represented by the second image, and samples quadrilinearly into it. The two arguments it takes are the width and height of each lenslet. The number of channels in the top image has to be 4, with the channels being the s,t,u and v coordinates in that order. An extra argument of 'quick' at the end switches nearest neighbor resampling on Usage: ImageStack -load lf.jpg -load lfmap.png -lfwarp 8 8 -save out.jpg

load

-load loads a file and places it on the top of the stack. ImageStack can load the following file formats:

.tmp files. This format is used to save temporary image data, and to interoperate with other programs that can load or save raw binary data. The format supports any number of frames and channels. A .tmp file starts with a header that containining five 32-bit integer values which represents frames, width, height, channels and type. Image data follows. types: 0: 32 bit floats (the default format, which matches the internal format) 1: 64 bit doubles 2: 8 bit unsigned integers 3: 8 bit signed integers 4: 16 bit unsigned integers 5: 16 bit signed integers 6: 32 bit unsigned integers 7: 32 bit signed integers 8: 64 bit unsigned integers 9: 64 bit signed integers

When saving, an optional second argument specifies the format. This may be any of int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, or correspondingly char, unsigned char, short, unsigned short, int, unsigned int, float, or double. The default is float32.

.hdr files. These always have three channels and one frame. They store data in a 4 bytes per pixel red green blue exponent (rgbe) format.

.jpg (or .jpeg) files. When saving, an optional second arguments specifies the quality. This defaults to 90. A jpeg image always has a single frame, and may have either one or three channels.

.png files. These have a bit depth of 8, and may have 1-4 channels. They may only have 1 frame.

.ppm files, of either 8 or 16 bit depth. When saving, an optional second argument, which defaults to 8, specifies the bit depth. ppm files always have three channels and one frame.

.tga files. These can have 1, 3, or 4 channels, are run-length encoded, and are low dynamic range.

.tiff (or .tif or .meg) files. When saving, an optional second argument specifies the format. This may be any of int8, uint8, int16, uint16, int32, uint32, float16, float32, float64, or correspondingly char, unsigned char, short, unsigned short, int, unsigned int, half, float, or double. The default is uint16.

.wav sound files. They are represented as one or two channel images with height and width of 1, but many frames.

.flo files. This format is used for optical flow evaluation. It stores 2-band float image for horizontal and vertical flow components.

.csv files. These contain comma-separated floating point values in text. Each scanline of the image corresponds to a line in the file. x and c are thus conflated, as are y and t. When loading csv files, ImageStack assumes 1 channel and 1 frame.

.pba files. This format is a human-readable space-separated 2D array of numbers. It is used by petabricks. Width and channels become columns of the file, and height and frames becomes rows.

Usage: ImageStack -load foo.jpg

loadarray

-loadarray loads raw arrays of various data types. It takes 6 arguments. The first is the filename to be loaded, the second is the data type, which must be one of: int8, uint8, int16, uint16, int32, uint32, float32, float64, or equivalently: char, unsigned char, short, unsigned short, int, unsigned int, float, double. The last four arguments specify the dimensions in the order width, height, frames, and channels. Bear in mind that ImageStack stores values internally as 32 bits floats, so information will be lost when double arrays are loaded. Integer formats are not scaled to lie between zero and one, this must be done manually with the -scale operation.

Usage: ImageStack -loadarray foo.bar uint8 640 480 1 3

loadblock

-loadblock loads a rectangular portion of a .tmp file. It is roughly equivalent to a load followed by a crop, except that the file need not fit in memory. The nine arguments are filename, x, y, t, and c offsets within the file, then width, height, frames, and channels. If seven arguments are given, all channels are loaded. If five arguments are given, all frames are used and the arguments specify x and y. If three arguments are given, they specify frames and all x, y, and channels are loaded. Loading out of bounds from the tmp file is permitted. Undefined areas will be zero-filled.

This example multiplies a 512x512x128x3 volume by two, without ever loading it all into memory: ImageStack -loadblock foo.tmp 0 0 0 0 512 512 64 3 \ -scale 2 -saveblock foo.tmp 0 0 0 0 ImageStack -loadblock foo.tmp 0 0 0 64 512 512 64 3 \ -scale 2 -saveblock foo.tmp 0 0 64 0

loadchannels

-loadchannels accepts a sequence of images and loads them as the channels of asingle stack entry. See the help for -load for details on file formats.

Usage: ImageStack -loadchannels foo*.jpg bar*.png

loadframes

-loadframes accepts a sequence of images and loads them as the frames of a single stack entry. See the help for -load for details on file formats.

-loadframes cannot be used on raw float files. To achieve the same effect, cat the files together and load them as a single multi-frame image.

Usage: ImageStack -loadframes foo*.jpg bar*.png

loadpanorama

-loadpanorama takes a filename as its first argument. The file must be the homography text file output from autostitch. It loads and parses this file, and places each warped image in a separate frame. The remaining six arguments specify minimum and maximum theta, then phi, then the desired output resolution.

Usage: ImageStack -loadpanorama pano.txt -0.1 0.1 -0.1 0.1 640 480 -display

locallaplacian

-locallaplacian modifies contrast at various scales. It is similar to the clarity slider in Photoshop. This operation is an implementation of Fast and Robust Pyramid-based Image Processing by Aubry et al, which is an acceleration of Local Laplacian Filters by Paris et al.

The first argument specifies how much of an effect to apply. 0 gives no effect, 1 produces a moderate amount of contrast enhancement, and -1 produces a piecewise flattening. The second argument specifies how the effect should change with respect to scale. 0 applies the same effect at all scales, -1 applies the effect only at coarse scales, and 1 applies the effect only at fine scales. Values larger than one actually reverse the effect at fine or coarse scales. In fact -locallaplacian 1 2 is an effective tone-mapper because it amplifies contrast at fine scales and reduces it at coarse scales.

Usage: ImageStack -load input.jpg -locallaplacian 1 0 -save boosted.jpg

localmaxima

-localmaxima finds local maxima in the image and outputs their locations to a text file. Each line in the text file consists of four comma-delimited floating point values, corresponding to the t, x and y coordinates, and the strength of the local maxima (its value minus the maximum neighbor). -localmaxima will only operate on the first channel of an image. There are three arguments. The first is some string containing the characters x, y, and t. It specifies the dimensions over which a pixel must be greater than its neighbors. The second is the minimum value by which a pixel must exceed its neighbors to count as a local maximum. The third is the minimum distance which must separate adjacent local maxima.

Usage: ImageStack -load stack.tmp -localmaxima txy 0.01 5 output.txt

log

-log takes the natural log of the current image.

Usage: ImageStack -load a.tga -log -load b.tga -log -add -exp -save product.tga.

loop

-loop takes an integer and a sequence of commands, and loops that sequence the specified number of times. The commands that form the argument must be prefixed with an extra dash. It is possible to nest this operation using more dashes. If given no integer argument, loop will loop forever.

Usage: ImageStack -load a.tga -loop 36 --rotate 10 --loop 10 ---downsample ---upsample -save b.tga

max

-max replaces the top image in the stack with the max of the top two images.

Usage: ImageStack -load a.tga -load b.tga -max -save out.tga.

medianfilter

-medianfilter applies a median filter with a circular support. The sole argument is the pixel radius of the filter.

Usage: ImageStack -load input.jpg -median 10 -save output.jpg

min

-min replaces the top image in the stack with the min of the top two images.

Usage: ImageStack -load a.tga -load b.tga -min -save out.tga.

mod

-mod takes the floating point modulus of the current image. It can either be called with a single argument, or with one argument per image channel. Usage: ImageStack -load a.tga -mod 0.5 34 2 -save b.tga

multiply

-multiply multiplies the top image in the stack by the second image in the stack. If one or both images are single-channel, then this performs a scalar-vector multiplication. If both images have multiple channels, there are three different vector-vector multiplications possible, selectable with the sole argument. Say the first image has k channels and the second image has j channels. "elementwise" performs element-wise multiplication. If k != j then the lesser is repeated as necessary. The output has max(k, j) channels. "inner" performs an inner, or matrix, product. It treats the image with more channels as containing matrices in row-major order, and the image with fewer channels as a column vector, and performs a matrix-vector multiplication at every pixel. The output has max(j/k, k/j) channels. "outer" performs an outer product at each pixel. The output image has j*k channels. If no argument is given, the multiplication will be "elementwise".

Usage: ImageStack -load a.tga -load b.tga -multiply -save out.tga.

nlmeans

-nlmeans denoises an image using non-local means, by performing a PCA reduction on Gaussian weighted patches and then doing a joint-bilateral filter of the image with respect to those PCA-reduced patches. The four arguments required are the standard deviation of the Gaussian patches used, the number of dimensions to reduce the patches to, the spatial standard deviation of the filter, and the patch-space standard deviation of the filter. Tolga Tasdizen demonstrates in "Principal Components for Non-Local Means Image Denoising" that 6 dimensions work best most of the time. You can optionally add a fifth argument that specifies which method to use for the joint bilateral filter (see -gausstransform).

Usage: ImageStack -load noisy.jpg -nlmeans 1.0 6 50 0.02

nlmeans3d

-nlmeans denoises an image using non-local means, by performing a PCA reduction on Gaussian weighted patches and then doing a joint-bilateral filter of the image with respect to those PCA-reduced patches. The four arguments required are the standard deviation of the Gaussian patches used, the number of dimensions to reduce the patches to, the spatial standard deviation of the filter, and the patch-space standard deviation of the filter. Tolga Tasdizen demonstrates in "Principal Components for Non-Local Means Image Denoising" that 6 dimensions work best most of the time. You can optionally add a fifth argument that specifies which method to use for the joint bilateral filter (see -gausstransform).

Usage: ImageStack -load noisy.jpg -nlmeans 1.0 6 50 0.02

noise

-noise adds uniform noise to the current image, uncorrelated across the channels, in the range between the two arguments. With one argument, the lower value is assumed to be zero. With no arguments, the range is assumed to be [0, 1]

Usage: ImageStack -load a.tga -push -noise -add -save anoisy.tga

normalize

-normalize restricts the image to be between 0 and 1 by rescaling and shifting it.

Usage: ImageStack -load a.exr -normalize -save a.tga

offset

-offset adds to the current image. It can either be called with a single argument, or with one argument per image channel. Usage: ImageStack -load a.tga -offset 0.5 34 2 -save b.tga

opticalflow

-opticalflow computes optical flow between two images based on ECCV 2004 paper from Brox et al.(see source code for credits), which is performed in multiple scales to handle big displacements. This operation returns a three-channel image with x and y pixel offset vectors, and energy cost which can be used as confidence measure for the estimation of each vector. If you have an initial estimate of flow vectors, you give three input images and give any value as an argument to indicate you want to use your initial estimate.

arguments [useInitialGuess] - useInitialGuess (default: none)

Usage: ImageStack -load target.jpg -load source.jpg -load guess.tmp -opticalflow 1 -save flow.tmp Usage: ImageStack -load target.jpg -load source.jpg -opticalflow -save flow.tmp

opticalflowwarp

-opticalflowwarp warps an image to match the other image based on optical flow estimation.

Usage: ImageStack -load from.jpg -load to.jpg -opticalflowwarp -save warped.jpg

panoramabackground

-panoramabackground takes aligned frames and computes what lies behind any objects that move across the frames.

Usage: ImageStack -loadpanorama pano.txt -panoramabackground -display

paste

-paste places some of the second image in the stack inside the top image, at the specified location. -paste accepts two or three, six, or nine arguments. When given two or three arguments, it interprets these as x and y, or x, y, and t, and pastes the whole of the second image onto that location in the first image. If six or nine arguments are given, the latter four or six arguments specify what portion of the second image is copied. The middle two or three arguments specify the top left, and the last two or three arguments specify the size of the region to paste.

The format is thus: -paste [desination origin] [source origin] [size]

Usage: ImageStack -load a.jpg -push 820 820 1 3 -paste 10 10 -save border.jpg

patchmatch

-patchmatch computes approximate nearest neighbor field from the top image on the stack to the second image on the stack, using the algorithm from the PatchMatch SIGGRAPH 2009 paper. This operation requires two input images which may have multiple frames. It returns an image with four channels. First three channels correspond to x, y, t coordinate of closest patch and fourth channels contains the sum of squared differences between patches.

arguments [numIter] [patchSize] - numIter : number of iterations performed. (default: 5) - patchSize : size of patch. (default: 7, 7x7 square patch) You can omit some arguments from right to use default values.

Usage: ImageStack -load target.jpg -load source.jpg -patchmatch -save match.tmp

patchpca

-patchpca treats local Gaussian neighbourhoods of pixel values as vectors and computes a stack of filters that can be used to reduce dimensionality and decorrelate the color channels. The two arguments are the standard deviation of the Gaussian, and the desired number of output dimensions. Patches near the edge of the image are not included in the covariance computation. Usage: ImageStack -load a.jpg -patchpca 2 8 -save filters.tmp -pull 1 -convolve zero inner -save reduced.tmp

patchpca3d

-patchpca3d treats local 3D Gaussian neighbourhoods of pixel values as vectors and computes a stack of filters that can be used to reduce dimensionality and decorrelate the color channels. The two arguments are the standard deviation of the Gaussian, and the desired number of output dimensions. Patches near the edge of the image are not included in the covariance computation. Usage: ImageStack -load volume.tmp -patchpca3d 2 8 -save filters.tmp -pull 1 -convolve zero inner -save reduced.tmp

pause

-pause waits for the user to press hit enter.

Usage: ImageStack -load a.tga -display -pause -load b.tga -display

pca

-pca reduces the number of channels in the image to the given parameter, using principal components analysis (PCA).

Usage: ImageStack -load a.jpg -pca 1 -save gray.png

percentilefilter

-percentilefilter selects a given statistical percentile over a circular support around each pixel. The two arguments are the support radius, and the percentile. A percentile argument of 0.5 gives a median filter, whereas 0 or 1 give min or max filters.

Usage: ImageStack -load input.jpg -percentilefilter 10 0.25 -save dark.jpg

plot

-plot takes images with height 1 and range [0, 1], and graphs them. It takes three arguments: the width and height of the resulting graph, and the line thickness to use for the plot. The resulting graph will have the same number of frames and channels as the input.

plugin

-plugin loads a shared object that can add new operations to ImageStack. It does this by calling the function init_imagestack_plugin, which should exist in the shared object with C linkage. To this function it passes the ImageStack operation map, into which the plugin may inject new operations.

Usage: ImageStack -plugin foo.so -foo 1 2 3

poisson

-poisson assumes the stack contains gradients images in x and y, and attempts to find the image which fits those gradients best in a least squares sense. It uses a preconditioned conjugate gradient descent method. It takes one argument, which is required RMS error of the result. This defaults to 0.01 if not given.

Usage: ImageStack -load dx.tmp -load dy.tmp -poisson 0.0001 -save out.tga

pop

-pop removes the top image from the stack

Usage: ImageStack -load a.tga -load b.tga -save b.gif -pop -save a.gif

printf

-printf evaluates and prints its arguments, using the first argument as a format string. The remaining arguments are all evaluated as floats, so use %%d, %%i, and other non-float formats with caution.

Usage: ImageStack -load foo.jpg -printf "Mean = %%f" "mean()"

pull

-pull brings a buried stack element to the top. -pull 0 does nothing. -pull 1 brings up the second stack element, and so on. -pull can also be given named arguments to retrieve images that have been stashed with -stash

Usage: ImageStack -load a.tga -load b.tga -save b.gif -pull 1 -save a.gif

push

-push adds a new zeroed image to the top of the stack. With no arguments it matches the dimensions of the current image. With 4 arguments (width, height, frames, and channels) it creates an image of that size. Given three arguments frames defaults to 1, and the arguments are taken as width, height, and channels.

Usage: ImageStack -load a.tga -push -add -scale 0.5 -multiply -save out.tga ImageStack -push 1024 1024 1 3 -offset 0.5 -save gray.tga

quantize

-quantize rounds all values down to the nearest multiple of the sole argument. If no argument is given, quantize rounds down to the nearest integer.

Usage: ImageStack -load test.jpg -quantize 1/128 -save test2.jpg

realcomplex

-realcomplex takes a "real" image, and converts it to a "complex" image, in which the even channels represent the real component and the odd channels represent the imaginary component.

Usage: ImageStack -load a.png -realcomplex -fft -display

receive

-receive sets up a TCP server and listens for an image (such as that sent by -send). The sole optional argument is the port to listen on. It defaults to 5678.

Usage: ImageStack -receive 5243 -save image.jpg

ImageStack -loop --receive --scale 2 --send somewhereelse

rectfilter

-rectfilter performs a iterated rectangular filter on the image. The four arguments are the filter width, height, frames, and the number of iterations. If three arguments are given, they are interpreted as frames, width, and height, and the number of iterations is assumed to be one. If two arguments are given they are taken as width and height, and frames is assumed to be one. If one argument is given it is taken as both width and height, with frames and iterations again assumed to be one.

Usage: ImageStack -load in.jpg -rectfilter 1 10 10 -save out.jpg

resample

-resample resamples the input using a 3-lobed Lanczos filter. When given three arguments, it produces a new volume of the given width, height, and frames. When given two arguments, it produces a new volume of the given width and height, with the same number of frames.

Usage: ImageStack -loadframes f*.tga -resample 20 50 50 -saveframes f%03d.tga

reshape

-reshape changes the way the memory of the current image is indexed. The four integer arguments specify a new width, height, frames, and channels.

Usage: ImageStack -load movie.tmp -reshape width height*frames 1 channels -save filmstrip.tmp

rotate

-rotate takes a number of degrees, and rotates every frame of the current image clockwise by that angle. The rotation preserves the image size, filling empty areas with zeros, and throwing away data which will not fit in the bounds.

Usage: ImageStack -load a.tga -rotate 45 -save b.tga

save

-save stores the image at the top of the stack to a file. The stack is not altered. The following file formats are supported:

.tmp files. This format is used to save temporary image data, and to interoperate with other programs that can load or save raw binary data. The format supports any number of frames and channels. A .tmp file starts with a header that containining five 32-bit integer values which represents frames, width, height, channels and type. Image data follows. types: 0: 32 bit floats (the default format, which matches the internal format) 1: 64 bit doubles 2: 8 bit unsigned integers 3: 8 bit signed integers 4: 16 bit unsigned integers 5: 16 bit signed integers 6: 32 bit unsigned integers 7: 32 bit signed integers 8: 64 bit unsigned integers 9: 64 bit signed integers

When saving, an optional second argument specifies the format. This may be any of int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, or correspondingly char, unsigned char, short, unsigned short, int, unsigned int, float, or double. The default is float32.

.hdr files. These always have three channels and one frame. They store data in a 4 bytes per pixel red green blue exponent (rgbe) format.

.jpg (or .jpeg) files. When saving, an optional second arguments specifies the quality. This defaults to 90. A jpeg image always has a single frame, and may have either one or three channels.

.png files. These have a bit depth of 8, and may have 1-4 channels. They may only have 1 frame.

.ppm files, of either 8 or 16 bit depth. When saving, an optional second argument, which defaults to 8, specifies the bit depth. ppm files always have three channels and one frame.

.tga files. These can have 1, 3, or 4 channels, are run-length encoded, and are low dynamic range.

.wav sound files. They are represented as one or two channel images with height and width of 1, but many frames.

.tiff (or .tif or .meg) files. When saving, an optional second argument specifies the format. This may be any of int8, uint8, int16, uint16, int32, uint32, float16, float32, float64, or correspondingly char, unsigned char, short, unsigned short, int, unsigned int, half, float, or double. The default is uint16.

.flo files. This format is used for optical flow evaluation. It stores 2-band float image for horizontal and vertical flow components.

.csv files. These contain comma-separated floating point values in text. Each scanline of the image corresponds to a line in the file. x and c are thus conflated, as are y and t. When loading csv files, ImageStack assumes 1 channel and 1 frame.

.pba files. This format is a human-readable space-separated 2D array of numbers. It is used by petabricks. Width and channels become columns of the file, and height and frames becomes rows.

Usage: ImageStack -load in.ppm -save out.jpg 98 ImageStack -load in.ppm -save out.jpg ImageStack -load in.ppm -save out.ppm 16

savearray

-savearray saves raw arrays of various data types. It takes 2 arguments. The first is the filename to be loaded, the second is the data type, which must be one of: int8, uint8, int16, uint16, int32, uint32, float32, float64, or equivalently: char, unsigned char, short, unsigned short, int, unsigned int, float, double.

Bear in mind that ImageStack stores values internally as 32 bit floats, so saving in double format does not give you higher fidelity.

Integer type formats are not scaled from the range zero to one. This must be done manually using the -scale operation.

Usage: ImageStack -load in.jpg -savearray out.float float32

saveblock

-saveblock overwrites a rectangular subblock of a .tmp file with the top of the stack. It is logically similar to a load, paste, save combination, but never loads the full tmp file. The five arguments are the filename, followed by the offset at which to paste the volume in x, y, t, and c. When given four arguments c is assumed to be zero. When given three arguments t is also set to zero. With two arguments, x, y, and c are set to zero.

This example multiplies a 128x512x512x3 volume by two, without ever loading it all into memory: ImageStack -loadblock foo.tmp 0 0 0 0 64 512 512 3 \ -scale 2 -saveblock foo.tmp 0 0 0 0 ImageStack -loadblock foo.tmp 64 0 0 0 64 512 512 3 \ -scale 2 -saveblock foo.tmp 0 0 0 0

savechannels

-savechannels takes a printf style format argument, and saves all the channels in the current image as separate files. See the help for save for details on file formats.

Usage: ImageStack -loadchannels *.jpg -savechannels frame%03d.png ImageStack -loadchannels *.jpg -savechannels frame%03d.ppm 16

saveframes

-saveframes takes a printf style format argument, and saves all the frames in the current image as separate files. See the help for save for details on file formats.

Usage: ImageStack -loadframes *.jpg -saveframes frame%03d.png ImageStack -loadframes *.jpg -saveframes frame%03d.ppm 16

scale

-scale scales the current image. It can either be called with a single argument, or with one argument per image channel. Usage: ImageStack -load a.tga -scale 0.5 34 2 -save b.tga

send

-send sends an image over a TCP connection. It has an optional first and second argument. The first argument specifies which server to contact, and the second argument specifies the port. By default, 127.0.0.1:5678 is used.

Usage: ImageStack -load a.tga -remotedisplay localhost 5678

shuffle

-shuffle takes every pixel in the current image and swaps it to a random new location creating a new noise image with exactly the same histogram.

Usage: ImageStack -load a.tga -shuffle -save shuffled.tga

sinugram

sort

-sort sorts the data along the given dimension for every value of the other dimensions. For example, the following command computes the median frame of a video.

ImageStack -loadframes frame*.jpg -sort t -crop frames/2 1 -save median.jpg

stash

-stash removes the top image from the stack and gives it a name. It can be retrieved using -dup or -pull using its name as the argument

Usage: ImageStack ... -stash foo ... -dup foo ... -pull foo

statistics

-statistics provides per channel statistical information about the current image.

Usage: ImageStack -load a.tga -statistics

subsample

-subsample subsamples the current image. Given two integer arguments, a and b, it selects one out of every a frames starting from frame b. Given four arguments, a, b, c, d, it selects one pixel out of every axb sized box, starting from pixel (c, d). Given six arguments, a, b, c, d, e, f, it selects one pixel from every axbxc volume, in the order width, height, frames starting at pixel (d, e, f).

Usage: ImageStack -load in.jpg -subsample 2 2 0 0 -save smaller.jpg

subtract

-subtract subtracts the second image in the stack from the top image in the stack.

Usage: ImageStack -load a.tga -load b.tga -subtract -save out.tga.

threshold

-threshold sets the image to zero where it is less than the argument, and sets it to one where it is greater than or equal to the argument.

Usage: ImageStack -load a.exr -threshold 0.5 -save monochrome.tga

tile

-tile repeats the image along each dimension. It interprets two arguments as repetitions in x and y. Three arguments are interpreted as repetitions in x, y, and t.

Usage: ImageStack -load a.tga -tile 2 2 -save b.tga

tileframes

-tileframes takes a volume and lays down groups of frames in a grid, dividing the number of frames by the product of the arguments. It takes two arguments, the number of old frames across each new frame, and the number of frames down. each new frame. The first batch of frames will appear as the first row of the. first frame of the new volume.

Usage: ImageStack -loadframes frame*.tif -tileframes 5 5 -saveframes sheet%d.tif

time

-time takes a sequence of commands, performs that sequence, and reports how long it took. The commands that form the argument must be prefixed with an extra dash. If given to arguments, it simply reports the time since the program was launched. It is a useful operation for profiling.

Usage: ImageStack -load a.jpg -time --resample 10 10 --scale 2

translate

-translate moves the image data, leaving black borders. It takes two or three arguments. Two arguments are interpreted as a shift in x and a shift in y. Three arguments indicates a shift in x, y, and t. Negative values shift to the top left and positive ones to the bottom right. Fractional shifts are permitted; Lanczos sampling is used in this case.

Usage: ImageStack -load in.jpg -translate -10 -10 -translate 20 20 -translate -10 -10 -save in_border.jpg

transpose

-transpose takes two dimension of the form 'x', 'y', or 't' and transposes the current image over those dimensions. If given no arguments, it defaults to x and y.

Usage: ImageStack -load a.tga -transpose x y -flip x -save rotated.tga

upsample

-upsample multiplies the width, height, and frames of the current image by the given integer arguments. It uses nearest neighbor interpolation. For a slower, high-quality resampling method, use -resample instead.

-upsample x y is interpreted as -upsample x y 1 -upsample x is interpreted as -upsample x x 1 -upsample is interpreted as -upsample 2 2 1

Usage: ImageStack -load a.tga -upsample 3 2 -save b.tga

warp

-warp treats the top image of the stack as indices (within [0, 1]) into the second image, and samples the second image accordingly. It takes no arguments. The number of channels in the top image is the dimensionality of the warp, and should be three or less.

Usage: ImageStack -load in.jpg -push -evalchannels "X+Y" "Y" -warp -save out.jpg

wls

-wls filters the image with the wls-filter described in the paper Edge-Preserving Decompositions for Multi-Scale Tone and Detail Manipulation by Farbman et al. The first parameter (alpha) controls the sensitivity to edges, and the second one (lambda) controls the amount of smoothing.

Usage: ImageStack -load in.jpg -wls 1.2 0.25 -save blurry.jpg