Skip to content

Xflow image processing operator list

einabadi edited this page Feb 18, 2013 · 6 revisions

Table of Contents

Basic Pixel-Wise Operations

xflow.grayscale

Converts an input color image to grayscale image.

s = 0.2126 * r + 0.7152 * g + 0.0722 * b

Signature

 output = xflow.grayscale(input)
 @param     texture     input       input color image
 @return    texture     output      output grayscale image

xflow.complement

Complements colors of an input image.

output = 255 - input (channel-wise)

Signature

 output = xflow.complement(input)
 @param     texture     input       input color image
 @return    texture     output      color complement of the input image

xflow.dim

Dims an input image by a ratio.

output = ratio * input (channel-wise)

Signature

 output = xflow.dim(input, ratio)
 @param     texture     input       input image
 @param     float       ratio       dimming ratio (positive)
 @return    texture     output      dimmed image

xflow.threshold

Thresholds an input grayscale image by a given threshold value.

output = (input > threshold) ? 255 : 0

Signature

 output = xflow.threshold(input, threshold)
 @param     texture     input       input grayscale image
 @param     int         threshod    threshold value [0,255]
 @return    texture     output      thresholded grayscale image

xflow.sliceColor

Slices an input image for colors of interest within an RGB sphere of a given radius centered at a given color. All other colors would become white.

Signature

 output = xflow.sliceColor(input, color, radius)
 @param     texture     input       input image
 @param     int         color       key color (color of interest)
 @param     float       radius      radius of the sphere centered at key color (positive)
 @return    texture     output      color sliced output image

xflow.mulColorMatrix

Multiplies a 4x4 float color weight matrix to an input image.

output = weights * input (matrix multiplication)

Signature

 output = xflow.mulColorMatrix(input, weights)
 @param     texture     input       input image
 @param     float       weights     4x4 color weight matrix
 @return    texture     output      output image with the new color tone

xflow.createSaturateMatrix

Creates a 4x4 saturate weight matrix according to a saturation degree (weight) to be used with xflow.mulColorMatrix. Weights are based on SVG filter effects.

Signature

 output = xflow.createSaturateMatrix(weight)
 @param     float       weight      weight value
 @return    float       output      a 4x4 saturate weight matrix

xflow.mask

Masks first image with second image according to a weight value.

output = input1 + weight * input2 (channel-wise)

Signature

 output = xflow.mask(input1, input2, weight)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @param     texture     weight      masking weight
 @return    texture     output      input1 masked with input2 result

xflow.getChannelMagnitude

Returns channel-wise magnitude (Euclidean norm) of two input images in a new image.

output = sqrt(input1^2 + input2^2) (channel-wise)

Signature

 output = xflow.getChannelMagnitude(input1, input2)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @return    texture     output      channel-wise magnitude of first and second input images

xflow.premultiply

Premultiplies color channels of input image pixels by their alpha values. Color channels of output image are still in the [0,255] range.

Signature

 output = xflow.premultiply(input)
 @param     texture     input       input color image (with channels in the range [0,255])
 @return    texture     output      premultiplied output image (with channels in the range [0,255])

xflow.unpremultiply

Unpremultiplies a premultiplied input color image according to the alpha values. Output image would be just a normal RGBA image which channels are in the range [0,255].

Signature

 output = xflow.unpremultiplies(input)
 @param     texture     input       premultiplied input image (with channels in the range [0,255])
 @return    texture     output      unpremultiplied output image (with channels in the range [0,255])

Blending Operations

All five blending operators are implemented based on SVG filter effect definitions with respect to alpha values. Inputs and outputs of the blending operators are just unpremultiplied images (normal RGBA).

xflow.blendNormal

Signature

 output = xflow.blendNormal(input1, input2)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @return    texture     output      blended output (Normal mode)

xflow.blendMultiply

Signature

 output = xflow.blendMultiply(input1, input2)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @return    texture     output      blended output (Multiply mode)

xflow.blendScreen

Signature

 output = xflow.blendScreen(input1, input2)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @return    texture     output      blended output (Screen mode)

xflow.blendLighten

Signature

 output = xflow.blendLighten(input1, input2)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @return    texture     output      blended output (Lighten mode)

xflow.blendDarken

Signature

 output = xflow.blendDarken(input1, input2)
 @param     texture     input1      first input image
 @param     texture     input2      second input image
 @return    texture     output      blended output (Darken mode)

Basic Spatial Filtering Operations

xflow.convolve

Convolves an input image by a given square spatial filter with odd sides.

Signature

 output = xflow.convolve(input, filter)
 @param     texture     input       input image
 @param     float       filter      square matrix of filter weights (with odd sides)
 @return    texture     output      convolution result image

xflow.createGaussianFilter

Creates a spatial 2D square Gaussian filter of given size (side) and sigma that can be used with xflow.convolve.

Signature

 output = xfow.createGaussianFilter(size, sigma)
 @param     int         size        side of the square filter (must be odd)
 @param     float       sigma       sigma of the Gaussian function (positive)
 @return    texture     output      square weight matrix of the desired Gaussian filter

xflow.createAveragingFilter

Creates a spatial 2D square Averaging filter of given size (side) that can be used with xflow.convolve.

Signature

 output = xflow.createAveragingFilter(size)
 @param     int     size        side of the square filter (must be odd)
 @return    float   output      square weight matrix of the desired Averaging filter

xflow.median

Convolves an input image by a square median filter of a given size.

Signature

 output = xflow.median(input, size)
 @param     texture     input       input image
 @param     int         size        side of the square median filter (must be odd)
 @return    texture     output      output image smoothed by the desired median filter

Morphology Operations

xflow.erode

Erodes an input color image by a given binary square morphological filter. All pixels in the input image which their corresponding filter values are 1 are considered in the filtering process. Erosion for color images is implemented using Minimum math function.

Signature

 output = xflow.erode(input, filter)
 @param     texture     input       input color image
 @param     int         filter      binary square morphological filter
 @return    texture     output      eroded output image

xflow.dilate

Dilates an input color image by a given binary square morphological filter. All pixels in the input image which their corresponding filter values are 1 are considered in the filtering process. Dilation for color images is implemented using Maximum math function.

Signature

 output = xflow.dilate(input, filter)
 @param     texture     input       input color image
 @param     int         filter      binary square morphological filter
 @return    texture     output      dilated output image

xflow.createSquareMorphologyFilter

Create a square morphological filter that all of its elements are 1.

Signature

 output = xflow.createSquareMorphologyFilter(size)
 @param     int     size        side of the square morphological filter (must be odd)
 @return    int     output      square morphological filter with 1 for all elements

Histogram Processing Operations

xflow.createHistogram

Creates histogram of a desired channel of an input image.

Signature

 histogram = xflow.createHistogram(input, channel)
 @param     texture     input       input image
 @param     int         channel     desired channel (must be 0, 1 or 2)
 @return    float       histogram   calculated histogram (an array of size 256)

xflow.createEqualizationHST

Creates equalization histogram transform (HST) of a given histogram.

Signature

 HST = xflow.createEqualizationHST(histogram)
 @param     float       histogram   input histogram (an array of size 256)
 @return    float       HST         calculated equalization HST for the input histogram

xflow.applyHST

Performs a given histogram transform (HST) on a desired channel of an input image.

Signature

 output = xflow.applyHST(input, HST, channel)
 @param     texture     input       input image
 @param     float       HST         histogram transform to be applied on the input image
 @param     int         channel     desired channel (must be 0, 1 or 2)
 @return    texture     output      output image

xflow.applyGrayscaleHST

Performs a given histogram transform (HST) on a grayscale input image.

Signature

 output = xflow.applyGrayscaleHST(input, HST)
 @param     texture     input       input grayscale image
 @param     float       HST         histogram transform to be applied on the input image
 @return    texture     output      output image

Padding and Cropping Operations

xflow.padToPow2

Pads width and height of an input image to the nearest powers of 2.

Signature

 (output, originalSize) = xflow.padToPow2(input)
 @param     texture     input           input image
 @return    texture     output          output padded image (each side to its nearest power of 2)
 @return    int         originalSize    width and height of the input image (an array of size 2)

xflow.crop

Crops input image according to the specified origin and the size.

Signature

 output = xflow.crop(input, origin, size)
 @param     texture     input       input image
 @param     int         origin      x and y of origin (an array of size 2)
 @param     int         size        width and height of the cropping area (an array of size 2)
 @return    texture     output      output cropped image

Frequency Domain Operations

xflow.applyDFT

Calculates Discrete Fourier Transform (DFT) of an grayscale input image. Output is a Float32 texture which its first and second channels are the amplitude and the phase components of the transformed input image, respectively.

Signature

 output = xflow.applyDFT(input)
 @param     texture     input       grayscale input image
 @return    texture     output      DFT of the input image (1st ch.: amplitude, 2nd ch.: phase, Float32)

xflow.applyDFTInv

Calculates Inverse Discrete Fourier Transform (DFTInv) of an input texture in the frequency domain. The input texture must have the same format as the output of xflow.applyDFT.

Signature

 output = xflow.applyDFTInv(input)
 @param     texture     input       DFT texture (1st ch.: amplitude, 2nd ch.: phase, Float32)
 @return    texture     output      output grayscale image in the spatial domain

xflow.applyFFT

Calculates Fast Fourier Transform (FFT) of an grayscale input image. Output is a Float32 texture which its first and second channels are the amplitude and the phase components of the transformed input image, respectively.

Here we apply radix-2 Cooley-Tukey FFT on subsequent rows and columns of the input image. Therefore, the width and height of the input image must be powers of 2.

Signature

 output = xflow.applyFFT(input)
 @param     texture     input       grayscale input image (each side must be power of 2)
 @return    texture     output      FFT of the input image (1st ch.: amplitude, 2nd ch.: phase, Float32)

xflow.applyFFTInv

Calculates Inverse Fast Fourier Transform (FFTInv) of an input texture in the frequency domain. The input texture must have the same format as the output of xflow.applyFFT.

Signature

 output = xflow.applyFFTInv(input)
 @param     texture     input       FFT texture (1st ch.: amplitude, 2nd ch.: phase)
 @return    texture     output      output grayscale image in the spatial domain

xflow.createSpectrumImage

Creates grayscale spectrum of a DFT / FFT texture in log10 scale.

Signature

 output = xflow.createSpectrumImage(input)
 @param     texture     input       DFT / FFT texture (1st ch.: amplitude, 2nd ch.: phase, Float32)
 @return    texture     output      log-scaled spectrum of the transformation

xflow.applyGaussianLPF

Applies the frequency domain Gaussian low pass filter (LPF) of a given sigma on the input image. Generated filter has the same size as input image.

Signature

 output = xflow.applyGaussianLPF(input, sigma)
 @param     texture     input       DFT / FFT texture (1st ch.: amplitude, 2nd ch.: phase, Float32)
 @param     float       sigma       sigma of the Gaussian function (positive)
 @return    texture     output      output DFT / FFT texture multiplied by the Gaussian LPF

xflow.applyGaussianHPF

Applies the frequency domain Gaussian high pass filter (HPF) of a given sigma on the input image. Generated filter has the same size as the input image.

Signature

 output = xflow.applyGaussianHPF(input, sigma)
 @param     texture     input       DFT / FFT texture (1st ch.: amplitude, 2nd ch.: phase, Float32)
 @param     float       sigma       sigma of the Gaussian function (positive)
 @return    texture     output      output DFT / FFT texture multiplied by the Gaussian HPF
Clone this wiki locally