Image Filtering — OpenCV 2.4.6.1 documentation

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.6.1 documentation »
- OpenCV API Reference »
- ocl. OpenCL-accelerated Computer Vision »

# Image Filtering

## ocl::Sobel

Returns void

C++:`` void `ocl::``Sobel`(const oclMat& src, oclMat& dst, int ddepth, int dx, int dy, int ksize=3, double scale=1, double delta=0.0, int bordertype=BORDER_DEFAULT)

  Parameters: | src – The source image dst – The destination image; It will have the same size as src ddepth – The destination image depth dx – Order of the derivative x dy – Order of the derivative y ksize – Size of the extended Sobel kernel scale – The optional scale factor for the computed derivative values(by default, no scaling is applied) delta – The optional delta value, added to the results prior to storing them in dst bordertype – Pixel extrapolation method.

The function computes the first x- or y- spatial image derivative using Sobel operator. Surpport 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data type.

## ocl::Scharr

Returns void

C++:`` void `ocl::``Scharr`(const oclMat& src, oclMat& dst, int ddepth, int dx, int dy, double scale=1, double delta=0.0, int bordertype=BORDER_DEFAULT)

  Parameters: | src – The source image dst – The destination image; It will have the same size as src ddepth – The destination image depth dx – Order of the derivative x dy – Order of the derivative y scale – The optional scale factor for the computed derivative values(by default, no scaling is applied) delta – The optional delta value, added to the results prior to storing them in dst bordertype – Pixel extrapolation method.

The function computes the first x- or y- spatial image derivative using Scharr operator. Surpport 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data type.

## ocl::GaussianBlur

Returns void

C++:`` void `ocl::``GaussianBlur`(const oclMat& src, oclMat& dst, Size ksize, double sigma1, double sigma2=0, int bordertype=BORDER_DEFAULT)

  Parameters: | src – The source image dst – The destination image; It will have the same size and the same type as src ksize – The Gaussian kernel size; ksize.width and ksize.height can differ, but they both must be positive and odd. Or, they can be zero’s, then they are computed from sigma sigma1sigma2 – The Gaussian kernel standard deviations in X and Y direction. If sigmaY is zero, it is set to be equal to sigmaX. If they are both zeros, they are computed from ksize.width and ksize.height. To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of ksize, sigmaX and sigmaY bordertype – Pixel extrapolation method.

The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported. Surpport 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data type.

## ocl::boxFilter

Returns void

C++:`` void `ocl::``boxFilter`(const oclMat& src, oclMat& dst, int ddepth, Size ksize, Point anchor=Point(-1, -1), int borderType=BORDER_DEFAULT)

  Parameters: | src – The source image dst – The destination image; It will have the same size and the same type as src ddepth – The desired depth of the destination image ksize – The smoothing kernel size. It must be positive and odd anchor – The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center. bordertype – Pixel extrapolation method.

Smoothes image using box filter.Supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4.

## ocl::Laplacian

Returns void

C++:`` void `ocl::``Laplacian`(const oclMat& src, oclMat& dst, int ddepth, int ksize=1, double scale=1)

  Parameters: | src – The source image dst – The destination image; It will have the same size and the same type as src ddepth – The desired depth of the destination image ksize – The aperture size used to compute the second-derivative filters. It must be positive and odd scale – The optional scale factor for the computed Laplacian values (by default, no scaling is applied

The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator.

## ocl::convolve

Returns void

C++:`` void `ocl::``convolve`(const oclMat& image, const oclMat& temp1, oclMat& result)

  Parameters: | image – The source image temp1 – Convolution kernel, a single-channel floating point matrix. result – The destination image

Convolves an image with the kernel. Supports only CV_32FC1 data types and do not support ROI.

## ocl::bilateralFilter

Returns void

C++:`` void `ocl::``bilateralFilter`(const oclMat& src, oclMat& dst, int d, double sigmaColor, double sigmaSpave, int borderType=BORDER_DEFAULT)

  Parameters: | src – The source image dst – The destination image; will have the same size and the same type as src d – The diameter of each pixel neighborhood, that is used during filtering. If it is non-positive, it’s computed from sigmaSpace sigmaColor – Filter sigma in the color space. Larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color sigmaSpave – Filter sigma in the coordinate space. Larger value of the parameter means that farther pixels will influence each other (as long as their colors are close enough; see sigmaColor). Then d>0, it specifies the neighborhood size regardless of sigmaSpace, otherwise d is proportional to sigmaSpace. borderType – Pixel extrapolation method.

Applies bilateral filter to the image. Supports 8UC1 8UC4 data types.

## ocl::copyMakeBorder

Returns void

C++:`` void `ocl::``copyMakeBorder`(const oclMat& src, oclMat& dst, int top, int bottom, int left, int right, int boardtype, const Scalar& value=Scalar())

  Parameters: | src – The source image dst – The destination image; will have the same type as src and the size size(src.cols+left+right, src.rows+top+bottom) topbottomleftright – Specify how much pixels in each direction from the source image rectangle one needs to extrapolate, e.g. top=1, bottom=1, left=1, right=1mean that 1 pixel-wide border needs to be built bordertype – Pixel extrapolation method. value – The border value if borderType==BORDER CONSTANT

Forms a border around the image. Supports 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data types.

## ocl::dilate

Returns void

C++:`` void `ocl::``dilate`(const oclMat& src, oclMat& dst, const Mat& kernel, Point anchor=Point(-1, -1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue())

  Parameters: | src – The source image dst – The destination image; It will have the same size and the same type as src kernel – The structuring element used for dilation. If element=Mat(), a 3times 3 rectangular structuring element is used anchor – Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center, only default value is supported iterations – The number of times dilation is applied bordertype – Pixel extrapolation method. value – The border value if borderType==BORDER CONSTANT

The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken. Supports 8UC1 8UC4 data types.

## ocl::erode

Returns void

C++:`` void `ocl::``erode`(const oclMat& src, oclMat& dst, const Mat& kernel, Point anchor=Point(-1, -1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue())

  Parameters: | src – The source image dst – The destination image; It will have the same size and the same type as src kernel – The structuring element used for dilation. If element=Mat(), a 3times 3 rectangular structuring element is used anchor – Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center, only default value is supported iterations – The number of times dilation is applied bordertype – Pixel extrapolation method. value – The border value if borderType==BORDER CONSTANT

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken. Supports 8UC1 8UC4 data types.

## ocl::morphologyEx

Returns void

C++:`` void `ocl::``morphologyEx`(const oclMat& src, oclMat& dst, int op, const Mat& kernel, Point anchor=Point(-1, -1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue())

  Parameters: | src – The source image dst – The destination image; It will have the same size and the same type as src op – Type of morphological operation, one of the following: ERODE DILTATE OPEN CLOSE GRADIENT TOPHAT BLACKHAT kernel – The structuring element used for dilation. If element=Mat(), a 3times 3 rectangular structuring element is used anchor – Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center, only default value is supported iterations – The number of times dilation is applied bordertype – Pixel extrapolation method. value – The border value if borderType==BORDER CONSTANT

A wrapper for erode and dilate. Supports 8UC1 8UC4 data types.

## ocl::pyrDown

Smoothes an image and downsamples it.

C++:`` void `ocl::``pyrDown`(const oclMat& src, oclMat& dst)

  Parameters: | src – Source image. dst – Destination image. Will have `Size((src.cols+1)/2, (src.rows+1)/2)` size and the same type as `src` .

See also

`pyrDown()`

## ocl::pyrUp

Upsamples an image and then smoothes it.

C++:`` void `ocl::``pyrUp`(const oclMat& src, oclMat& dst)

  Parameters: | src – Source image. dst – Destination image. Will have `Size(src.cols*2, src.rows*2)` size and the same type as `src` .

See also

`pyrUp()`

## ocl::columnSum

Computes a vertical (column) sum.

C++:`` void `ocl::``columnSum`(const oclMat& src, oclMat& sum)

  Parameters: | src – Source image. Only `CV_32FC1` images are supported for now. sum – Destination image of the `CV_32FC1` type.

## ocl::blendLinear

Performs linear blending of two images.

C++:`` void `ocl::``blendLinear`(const oclMat& img1, const oclMat& img2, const oclMat& weights1, const oclMat& weights2, oclMat& result)

  Parameters: | img1 – First image. Supports only `CV_8U` and `CV_32F` depth. img2 – Second image. Must have the same size and the same type as `img1` . weights1 – Weights for first image. Must have tha same size as `img1` . Supports only `CV_32F` type. weights2 – Weights for second image. Must have tha same size as `img2` . Supports only `CV_32F` type. result – Destination image.

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.6.1 documentation »
- OpenCV API Reference »
- ocl. OpenCL-accelerated Computer Vision »