In all of the following functions, two-dimensional sizes, offsets, locations, etc., are passed to functions in lists. For example, a two-dimensional size is specified as [xsize ysize].
image-copy creates an identical copy of an image by creating a new buffer and transfering the old image into it. The return value is the new image buffer.
image-filter-1d convolves each scanline in the input image with a one-dimensional filter and places the result in the output image which must be the same size. taps should be a list of real numbers of arbitrary length specifying the filter taps. centertap should be an integer index indicating the center of the tap list. mirror-flag should be True if the image should be "mirrored" to provide better filter output at the edges, and False if not (slightly faster).
image-filter-2d performs a two-dimensional convolution over the entire image. taps should be a list of lists of real numbers indicating the taps for each "line" of the filter, and centertap should be a list of two integers [xcenter ycenter] indicating the center of the tap array. The rest of the arguments are the same as before.
image-remap-intensity works only on byte-sampled images. It remaps the pixel values in the input image and places the result in the output image. remapaddr is the address of a 256-byte array specifying the correspondance between new and old pixel values. For example, to remap all pixels which have the value 3 to have the new value 159, remapaddr should have the value 159 at index 3. You can create this array using the utilities in the memory manipulation library.
The return value in all cases is the output image buffer.
image-fuzzy-bounding-box is a fuzzy bounding box algorithm that is helpful in eliminating the effects of salt and pepper noise when looking for bounding boxes. The function returns the smallest rectangle that bounds all areas of the image where the sum of pixcount adjacent horizontal pixels is greater than or equal to thresh. The return value is the same as before.
inbuf is an image buffer containing an alpha plane which defines multiple foreground objects against a single background. The background pixels are marked with a '0' while the pixels of the foreground objects are those with non-zero values. Data type is either c-short or c-byte.
seed-point is a pixel position in the alpha plane. Starting from the seed point, all foreground pixels which have an unbroken connection to the seed point are selected via flood fill.
On completion outbuf contains an alpha plane with the single selected foreground object marked with 1's and the remainder marked with 0's. Specification of an outbuf is optional. If no preallocated buffer is supplied, one is created and returned. Data type is c-byte.
This function is principally characterized by its speed. The flood fill routine has been hand optimized for use on machines with a 64-bit wide machine word. The throughput is 56 pixel positions per 8 machine clock cycles.
There is no differentiation between the foreground objects based on the values in the alpha plane. Any non-zero value denotes a foreground pixel and distinct foreground objects must be separated by background pixels.
image-composite expects the input foreground image, alpha image, and output background image as arguments and performs the standard composition as described above.
image-composite-constalpha composites an input image into an output image using a constant "alpha" value which must be an integer between 0 and 255.
image-composite-remapalpha works the same as image-composite except that each value in the alpha image is first "remapped" to a new value. remapaddr should be the address of a 256-byte array specifying the correspondance between new and old alpha values. One way to create this array is to use the utilities in the memory manipulation library.
The other five scaling functions work the same way as image-transfer, image-transfer-range, image-composite, image-composite-constalpha, and image-composite-remapalpha except that they scale the image as it is being processed. Two arguments, xremapaddr and yremapaddr, are expected in addition to the normal arguments for these operations. These arguments are addresses of arrays of integers indicating how to remap the image in the horizontal and vertical directions. Each value in the array indicates the location in the input image from which to obtain the value for each pixel in the output image. For example, a value of 34 at position 12 means that the 34th pixel in the input image will be transferred to the 12th position in the output image. Therefore, these arrays must be at least the length of the corresponding dimension of the output image.
new-scale-remap can be used to create an array of length linelen appropriate for remapping pixels at a particular exact scale factor. The return value of this function is the address of the array which should be freed when no longer needed. To create remap arrays for more complex transformations, use the utilities in the memory manipulation library.
image-affine-trans applies the affine transformation to an image. affine-params should be the list of 6 real number affine parameters obtained from using the routines described above. reverse-flag should be a boolean indicating whether the remapping should be performed in a forward (False) or reverse (True) fashion. In almost all cases, reverse-flag should be True. The final two arguments are the input and output image buffers which must be of the same type. The return value is the output image buffer. Pixels laying outside the boundaries of the input or output image buffers are not transferred.
affine-trans-point transforms a single point [xpos ypos] using the specified affine parameters.
All four parameters must be single channel image buffers of identical size. Both image buffers should be c-byte datatype. The displacement buffers should be type c-float.
This function uses gradient constraint to compute the displacement due to motion between the two images. Gradient constraint is a variant of optical flow which has been optimized for recovering the motion in natural scenes. This particular realization, based on the PhD theses of Dennis Martinez and Ed Krause, employs a series of hierarchical refinements to the vector field ... resulting in very robust estimates but a run time that is somewhat slow.
image-warp-map generates a suitable remapping image for a source image of size srcsize from a list of 6 affine parameters. warpbuf must be a two-channel integer-sampled image. Use the affine- functions described above to calculate affine parameters.
It is possible to have a fractional mapping, e.g. Dest[10 10] = Src[9.25 10.25]. In order to provide for fast, efficient interpolation methods, fixed point mathematics is used in the remapping. image-warp-map generates the correct fixed-point integer warp map for a given set of affine paramters. If another routine for generating the warp map will be used, it must follow the same fixed-point strategy: The last 8 bits are for the mantissa (i.e. fractional part) and the upper 24 bits are for the whole number. In order to convert a floating point number, say 9.25, to a fixed point integer, just multiply the whole number by 256, and typecast to an integer. So 9.25 * 256 = 2368.
If interp-flag is True, then tri-linear interpolation on the source data is performed. Otherwise, the fractional index is truncated. Tri-linear interpolation is slower than truncation but looks better.
No boundary checking is done on the position values in the remapping image. If you use your own warp-map generator, be sure to specify mappings that are always within the bounds of the source image. image-warp-map satisfies this requirement.
(set input-image (retrieve-url-image "file:/usr/local/isis/media/nana.jpg")) (set inputsize (input-image buf-size)) (set output-image (new-image c-byte 3 [300 300])) (set remap-image (new-image c-int 2 [300 300])) (set params (affine-combine (affine-translate (* [-0.5 -0.5] inputsize)) (affine-scale 0.5) (affine-rotate 45) (affine-translate [150 150]))) (image-warp-map params inputsize remap-image) (image-warp False input-image output-image remap-image) (set inwin (xwin-create Null "Original" Null inputsize)) (xwin-display-image inwin input-image) (set outwin (xwin-create Null "Warped" Null [300 300])) (xwin-display-image outwin output-image)
Scripts: | (load "image-processing.isis")
|
Libraries: | -lisis_improc
|
Headers: | isis_improc.h
|
Binders: | bind_improc_library(script);
|