Image Action Set
The processImages Action
The processImages action performs single or multiple image processing functions on input images. The input of this action is a CAS table that contains images and an array of functions (with their specific parameters). The output is a CAS table that contains the resulting images after the specified functions are applied. You can specify the following functions:
- RESIZE
resizes an input image based on the
widthandheightparameters. The parameters must be specified as positive integers.- GET_PATCH
creates a patch based on a rectangular region (using
x,y,width, andheightparameters) from an input image. Thexandyparameters must be specified as integers that are greater than or equal to 0. Thewidthandheightparameters must be specified as positive integers. Further, ifx+widthis greater than the specified width of the input image, then the width of the rectangular region is reduced to the input image’s specified width. The same is true for theyandheightparameters.- CANNY_EDGE
detects edges in input images by using the Canny edge detection algorithm. This function accepts three parameters:
lowThreshold,highThreshold, andkernelSize.- LAPLACIAN
applies the Laplace operator to input images. The Laplace operator is a second-order differential operator in the n-dimensional Euclidean space. When the value of the
kernelSizeparameter is 1, the resulting value is approximated by convolving the following kernel with input images:Otherwise, the value is approximated by summing the second x and y derivatives, which are calculated using the Sobel operator.
- SOBEL
uses the Sobel operator to calculate the first, second, third, or mixed image derivatives. Derivatives are calculated by convolving the image with a kernel. Kernels must be square. The size can only be one of the following numbers: 1, 3, 5, and 7. When the kernel size is 1, a kernel is used for the first or second derivative of x, and a kernel is used for the first or second derivative of y. For the other kernel sizes, the Sobel operator considers Gaussian smoothing and differentiation together (handling noise). The following kernel is used when the
kernelSize,dx, anddyparameters have the values 3, 1, and 0, respectively:The following kernel is used when they have the values 3, 0, and 1, respectively:
- NORMALIZE
normalizes the value range of an image. You can specify the following normalization functions in the
typeparameter: INF, L1, L2, L2SQR, HAMMING, HAMMING2, RELATIVE, and MINMAX. The MINMAX function is commonly used to normalize an image between alpha and beta values.- THRESHOLD
applies a threshold value to each pixel in an image. You can specify the following threshold types: BINARY, BINARY_INVERSE, TRUNCATE, TO_ZERO, TO_ZERO_INVERSE, OTSU, and TRIANGLE.
- CONVERT_COLOR
converts an image’s color space. Currently available conversions are COLOR2GRAY, GRAY2COLOR, BGR2RGB, and RGB2BGR. The default color space for an image is BGR. COLOR2GRAY means BGR2GRAY.
- RESCALE
changes an image’s depth. You can specify the following types of rescaling: TO_8U (depth is changed to 8-bit, where a pixel is represented by an unsigned integer), TO_32F (depth is changed to 32-bit, where a pixel is represented by a floating number), and TO_64F (depth is changed to 64-bit, where a pixel is represented by a double-precision number). You can scale the values based on the
alphaandbetaparameters.- MORPHOLOGY
performs a morphological transformation on images. You can specify the following types of transformation: ERODE, DILATE, OPEN, CLOSE, GRADIENT, TOPHAT, BLACKHAT, and HITMISS. Each of these operations can be in RECT (rectangular), CROSS, and ELLIPSE shapes.
- BOX_FILTER
blurs an image by using a normalized box filter. The
kernelWidthandkernelHeightparameters shape the filter. The anchor is assumed to be at the kernel’s center.- GAUSSIAN_FILTER
blurs an image by using a Gaussian filter. A convolution kernel is created based on the
kernelWidthandkernelHeightparameters, which must be positive and odd.- BILATERAL_FILTER
applies a bilateral filter to images. A bilateral filter is a nonlinear, edge-preserving, noise-reducing smoothing filter. The idea behind this filter is to consider pixels close if they are in spatially nearby locations, and similar if they have nearby values (in color space).
- MEDIAN_FILTER
blurs an image by using the median filter. This filter uses a square matrix of the size specified in the
kernelSizeparameter, which must be greater than 1 and odd.- BUILD_PYRAMID
blurs an image and samples it down (PYR_DOWN) or up (PYR_UP). A Gaussian kernel is used for blurring.
- CONTOURS
applies a number of preprocessing steps for more accurate results. This function accepts only one-channel images (for example, gray scale images). It provides better results when the input image is a binarized image (for example, pixel values are either black or white). If you provide a gray scale image rather than a binarized image, you will still see results but they might be inaccurate or unexpected (for example, a contour could look like a frame that contains the whole picture).
- CUSTOM_FILTER
creates a custom filter and uses it in convolution. This operation takes the width, height, and values of a filter.
- ADD_CONSTANT
adds or subtracts a constant value from the pixel intensity values input images. This function also makes sure that the resulting values are in the permitted range that is determined by the depth of a pixel. For example, if an image’s pixel depth is unsigned 8-bit (which means that the pixel values can be between 0 and 255 only), then this function makes sure that the resulting values are within the range of 0 and 255 ( no overflows and negative values are permitted in this case). Furthermore, if the image is a one-channel image, then the function uses only the constant value of the first input.
- HIST_EQUALIZATION
aims to stretch out the intensity range. This function maps the intensity distribution of an input image to another distribution that is wider and has a more uniform distribution of intensity values. Two versions are supported: global and adaptive. In the global version, the mapping is applied by considering the whole image. In the adaptive version, the mapping is performed in local patches of input images. Therefore, the adaptive version is more robust to images where contrast is quite different at different regions of those images.
- LINEAR_TRANSFORMATION
performs linear transformation in one of the following ways, based on the value of the
methodparameter:STANDARDIZATION creates an image that has zero mean and unit variance.
WHITENING_PCA uses principal component analysis to create an image that has an identity covariance.
WHITENING_ZCA uses a ZCA transformation (also called a Mahalanobis transformation) to create an image that has an identity covariance.
LOCAL_CONTRAST_NORM is similar to STANDARDIZATION except that it convolves a 9 9 Gaussian image with the input image.
- MUTATIONS
mutates images by using different augmentation techniques: flipping vertically, flipping horizontally, scaling up and down with pyramids, changing the contrast (darkening or lightening), sharpening, and rotating to the left or right. This function is useful for increasing the variety of the input images, which is a major preprocessing step for training methods that are based on deep neural networks.