OpenCV 4.12.0
開源計算機視覺
載入中...
搜尋中...
無匹配項
圖形 API:影像濾鏡

詳細描述

函式

GMat cv::gapi::bilateralFilter (const GMat &src, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT)
 對影像應用雙邊濾波。
 
GMat cv::gapi::blur (const GMat &src, const Size &ksize, const Point &anchor=Point(-1,-1), int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 使用歸一化盒式濾波器模糊影像。
 
GMat cv::gapi::boxFilter (const GMat &src, int dtype, const Size &ksize, const Point &anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 使用方框濾波器模糊影像。
 
GMat cv::gapi::dilate (const GMat &src, const Mat &kernel, const Point &anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
 使用特定的結構元素對影像進行膨脹。
 
GMat cv::gapi::dilate3x3 (const GMat &src, int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
 使用 3x3 矩形結構元素對影像進行膨脹。
 
GMat cv::gapi::erode (const GMat &src, const Mat &kernel, const Point &anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
 使用特定的結構元素對影像進行腐蝕。
 
GMat cv::gapi::erode3x3 (const GMat &src, int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
 使用 3x3 矩形結構元素對影像進行腐蝕。
 
GMat cv::gapi::filter2D (const GMat &src, int ddepth, const Mat &kernel, const Point &anchor=Point(-1,-1), const Scalar &delta=Scalar(0), int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 使用核函式對影像進行卷積。
 
GMat cv::gapi::gaussianBlur (const GMat &src, const Size &ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 使用高斯濾波器模糊影像。
 
GMat cv::gapi::Laplacian (const GMat &src, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT)
 計算影像的拉普拉斯運算元。
 
GMat cv::gapi::medianBlur (const GMat &src, int ksize)
 使用中值濾波器模糊影像。
 
GMat cv::gapi::morphologyEx (const GMat &src, const MorphTypes op, const Mat &kernel, const Point &anchor=Point(-1,-1), const int iterations=1, const BorderTypes borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
 執行高階形態學變換。
 
GMat cv::gapi::sepFilter (const GMat &src, int ddepth, const Mat &kernelX, const Mat &kernelY, const Point &anchor, const Scalar &delta, int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 對矩陣(影像)應用可分離線性濾波器。
 
GMat cv::gapi::Sobel (const GMat &src, int ddepth, int dx, int dy, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 使用擴充套件Sobel運算元計算一階、二階、三階或混合影像導數。
 
std::tuple< GMat, GMatcv::gapi::SobelXY (const GMat &src, int ddepth, int order, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT, const Scalar &borderValue=Scalar(0))
 使用擴充套件Sobel運算元計算一階、二階、三階或混合影像導數。
 

函式文件

◆ bilateralFilter()

GMat cv::gapi::bilateralFilter ( const GMat & src,
int d,
double sigmaColor,
double sigmaSpace,
int borderType = BORDER_DEFAULT )
Python
cv.gapi.bilateralFilter(src, d, sigmaColor, sigmaSpace[, borderType]) -> retval

#include <opencv2/gapi/imgproc.hpp>

對影像應用雙邊濾波。

該函式對輸入影像應用雙邊濾波,如 http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html 所述。雙邊濾波在很好地減少不需要的噪聲的同時,能保持邊緣相當銳利。然而,與大多數濾鏡相比,它非常慢。

Sigma 值:為了簡單起見,您可以將兩個 sigma 值設為相同。如果它們很小(< 10),濾鏡效果不明顯;如果它們很大(> 150),濾鏡效果會非常強,使影像看起來像“卡通片”。

濾鏡尺寸:大型濾鏡(d > 5)非常慢,因此建議即時應用使用 d=5,而需要大量去噪的離線應用則可以使用 d=9。

此濾波器不支援原地操作。

注意
函式文字ID為 "org.opencv.imgproc.filters.bilateralfilter"
引數
srcSource 8-bit or floating-point, 1-channel or 3-channel image.
d濾波過程中使用的每個畫素鄰域的直徑。如果它是非正值,則從 sigmaSpace 計算。
sigmaColor顏色空間中的濾鏡sigma。該引數值越大意味著畫素鄰域內(參見sigmaSpace)距離較遠的顏色也會混合在一起,從而形成更大的半等色區域。
sigmaSpace座標空間中的濾鏡sigma。該引數值越大意味著距離較遠的畫素只要顏色足夠接近就會相互影響(參見sigmaColor)。當 d>0 時,它指定鄰域大小,而與 sigmaSpace 無關。否則,d 與 sigmaSpace 成比例。
borderType用於推斷影像外部畫素的邊界模式,參見 BorderTypes
返回
與 src 相同大小和型別的輸出影像。

◆ blur()

GMat cv::gapi::blur ( const GMat & src,
const Size & ksize,
const Point & anchor = Point(-1,-1),
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.blur(src, ksize[, anchor[, borderType[, borderValue]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用歸一化盒式濾波器模糊影像。

該函式使用以下核平滑影像

\[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\]

呼叫 blur(src, ksize, anchor, borderType) 等價於 boxFilter(src, src.type(), ksize, anchor, true, borderType)

支援的輸入矩陣資料型別為 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.blur"
引數
src源影像。
ksize模糊核心大小。
anchor錨點;預設值 Point(-1,-1) 表示錨點位於核的中心。
borderType用於推斷影像外部畫素的邊界模式,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
boxFilter, bilateralFilter, GaussianBlur, medianBlur

◆ boxFilter()

GMat cv::gapi::boxFilter ( const GMat & src,
int dtype,
const Size & ksize,
const Point & anchor = Point(-1,-1),
bool normalize = true,
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.boxFilter(src, dtype, ksize[, anchor[, normalize[, borderType[, borderValue]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用方框濾波器模糊影像。

該函式使用以下核平滑影像

\[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\]

其中

\[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise} \end{cases}\]

非歸一化盒式濾鏡對於計算每個畫素鄰域上的各種積分特性很有用,例如影像導數的協方差矩陣(用於稠密光流演算法等)。如果需要計算可變大小視窗的畫素和,請使用 cv::integral

支援的輸入矩陣資料型別為 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.boxfilter"
引數
src源影像。
dtype輸出影像的深度(-1 表示設定輸入影像資料型別)。
ksize模糊核心大小。
anchor錨點在核內的位置。預設值 \((-1,-1)\) 表示錨點位於核的中心。
normalize標誌,指定核是否按其面積歸一化。
borderType畫素外推法,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
sepFilter, gaussianBlur, medianBlur, integral

◆ dilate()

GMat cv::gapi::dilate ( const GMat & src,
const Mat & kernel,
const Point & anchor = Point(-1,-1),
int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar & borderValue = morphologyDefaultBorderValue() )
Python
cv.gapi.dilate(src, kernel[, anchor[, iterations[, borderType[, borderValue]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用特定的結構元素對影像進行膨脹。

該函式使用指定的結構元素膨脹源影像,該結構元素確定了取最大值的畫素鄰域的形狀

\[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\]

膨脹可以應用多次 (iterations)。對於多通道影像,每個通道獨立處理。支援的輸入矩陣資料型別有 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.dilate"
引數
src輸入影像。
kernel用於膨脹的結構元素;如果 elemenat=Mat(),則使用 3x3 矩形結構元素。核可以使用 getStructuringElement 建立。
anchor錨點在元素中的位置;預設值 (-1, -1) 表示錨點位於元素的中心。
iterations應用膨脹的次數。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界情況下的邊界值
另請參見
erode, morphologyEx, getStructuringElement

◆ dilate3x3()

GMat cv::gapi::dilate3x3 ( const GMat & src,
int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar & borderValue = morphologyDefaultBorderValue() )
Python
cv.gapi.dilate3x3(src[, iterations[, borderType[, borderValue]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用 3x3 矩形結構元素對影像進行膨脹。

該函式使用指定的結構元素膨脹源影像,該結構元素確定了取最大值的畫素鄰域的形狀

\[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\]

膨脹可以應用多次 (iterations)。對於多通道影像,每個通道獨立處理。支援的輸入矩陣資料型別有 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.dilate"
引數
src輸入影像。
iterations應用膨脹的次數。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界情況下的邊界值
另請參見
dilate, erode3x3

◆ erode()

GMat cv::gapi::erode ( const GMat & src,
const Mat & kernel,
const Point & anchor = Point(-1,-1),
int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar & borderValue = morphologyDefaultBorderValue() )
Python
cv.gapi.erode(src, kernel[, anchor[, iterations[, borderType[, borderValue]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用特定的結構元素對影像進行腐蝕。

該函式使用指定的結構元素腐蝕源影像,該結構元素確定了取最小值的畫素鄰域的形狀

\[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\]

腐蝕可以應用多次 (iterations)。對於多通道影像,每個通道獨立處理。支援的輸入矩陣資料型別有 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.erode"
引數
src輸入影像
kernel用於腐蝕的結構元素;如果 element=Mat(),則使用 3x3 矩形結構元素。核可以使用 getStructuringElement 建立。
anchor錨點在元素中的位置;預設值 (-1, -1) 表示錨點位於元素的中心。
iterations應用腐蝕的次數。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界情況下的邊界值
另請參見
dilate, morphologyEx

◆ erode3x3()

GMat cv::gapi::erode3x3 ( const GMat & src,
int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar & borderValue = morphologyDefaultBorderValue() )
Python
cv.gapi.erode3x3(src[, iterations[, borderType[, borderValue]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用 3x3 矩形結構元素對影像進行腐蝕。

該函式使用矩形結構元素和以矩形中心為錨點對源影像進行腐蝕。腐蝕可以應用多次(iterations)。對於多通道影像,每個通道獨立處理。支援的輸入矩陣資料型別有 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.erode"
引數
src輸入影像
iterations應用腐蝕的次數。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界情況下的邊界值
另請參見
erode, dilate3x3

◆ filter2D()

GMat cv::gapi::filter2D ( const GMat & src,
int ddepth,
const Mat & kernel,
const Point & anchor = Point(-1,-1),
const Scalar & delta = Scalar(0),
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.filter2D(src, ddepth, kernel[, anchor[, delta[, borderType[, borderValue]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用核函式對影像進行卷積。

該函式對影像應用任意線性濾鏡。當光圈部分超出影像時,該函式根據指定的邊界模式插值異常畫素值。

該函式實際計算的是相關,而不是卷積

\[\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\]

也就是說,核不會圍繞錨點映象。如果需要真正的卷積,請使用 flip 翻轉核,並將新錨點設定為 (kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)

支援的矩陣資料型別有 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1。輸出影像必須與輸入影像具有相同的大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.filter2D"
引數
src輸入影像。
ddepth目標影像所需的深度
kernel卷積核(或者更確切地說是相關核),一個單通道浮點矩陣;如果想對不同通道應用不同的核,可以使用 split 將影像分割成單獨的顏色平面並分別處理。
anchor核的錨點,表示濾波點在核內的相對位置;錨點應位於核內;預設值 (-1,-1) 表示錨點位於核的中心。
delta可選值,在將濾波後的畫素儲存到 dst 之前新增到它們。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
sepFilter

◆ gaussianBlur()

GMat cv::gapi::gaussianBlur ( const GMat & src,
const Size & ksize,
double sigmaX,
double sigmaY = 0,
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.gaussianBlur(src, ksize, sigmaX[, sigmaY[, borderType[, borderValue]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用高斯濾波器模糊影像。

該函式使用指定的高斯核對源影像進行 filter2Ds 操作。輸出影像必須與輸入影像具有相同的型別和通道數。

支援的輸入矩陣資料型別為 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.gaussianBlur"
引數
src輸入影像;
ksize高斯核大小。ksize.width 和 ksize.height 可以不同,但它們都必須是正奇數。或者,它們可以為零,然後從 sigma 計算。
sigmaXX 方向上的高斯核心標準差。
sigmaYY方向上的高斯核標準差;如果 sigmaY 為零,則將其設為等於 sigmaX;如果兩個 sigma 都為零,則分別從 ksize.width 和 ksize.height 計算(詳見 cv::getGaussianKernel);為了完全控制結果,無論未來對所有這些語義可能進行的修改,建議指定 ksize、sigmaX 和 sigmaY 的所有值。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
sepFilter, boxFilter, medianBlur

◆ Laplacian()

GMat cv::gapi::Laplacian ( const GMat & src,
int ddepth,
int ksize = 1,
double scale = 1,
double delta = 0,
int borderType = BORDER_DEFAULT )
Python
cv.gapi.Laplacian(src, ddepth[, ksize[, scale[, delta[, borderType]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

計算影像的拉普拉斯運算元。

該函式透過疊加使用Sobel運算元計算的二階x和y導數來計算源影像的拉普拉斯運算元

\[\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\]

ksize > 1 時,會進行此操作。當 ksize == 1 時,拉普拉斯運算元透過使用以下 \(3 \times 3\) 光圈對影像進行濾波來計算

\[\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\]

注意
函式文字ID為 "org.opencv.imgproc.filters.laplacian"
引數
src源影像。
ddepth目標影像的所需深度。
ksize用於計算二階導數濾鏡的孔徑大小。詳情請參見 getDerivKernels。大小必須為正奇數。
scale計算出的拉普拉斯值的可選比例因子。預設情況下不應用縮放。詳情請參見 getDerivKernels
delta在將結果儲存到 dst 之前新增到結果中的可選 delta 值。
borderType畫素外推方法,參見 BorderTypes。不支援 BORDER_WRAP
返回
目標影像與 src 具有相同的大小和通道數。
另請參見
Sobel, Scharr

◆ medianBlur()

GMat cv::gapi::medianBlur ( const GMat & src,
int ksize )
Python
cv.gapi.medianBlur(src, ksize) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用中值濾波器模糊影像。

該函式使用 \(\texttt{ksize} \times \texttt{ksize}\) 孔徑的中值濾鏡平滑影像。多通道影像的每個通道獨立處理。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。中值濾鏡內部使用 cv::BORDER_REPLICATE 來處理邊界畫素,參見 cv::BorderTypes
  • 函式文字ID為 "org.opencv.imgproc.filters.medianBlur"
引數
src輸入矩陣(影像)
ksize孔徑線性大小;必須是大於1的奇數,例如:3、5、7...
另請參見
boxFilter, gaussianBlur

◆ morphologyEx()

GMat cv::gapi::morphologyEx ( const GMat & src,
const MorphTypes op,
const Mat & kernel,
const Point & anchor = Point(-1,-1),
const int iterations = 1,
const BorderTypes borderType = BORDER_CONSTANT,
const Scalar & borderValue = morphologyDefaultBorderValue() )
Python
cv.gapi.morphologyEx(src, op, kernel[, anchor[, iterations[, borderType[, borderValue]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

執行高階形態學變換。

該函式可以使用腐蝕和膨脹作為基本操作來執行高階形態學變換。

任何操作都可以在原地完成。對於多通道影像,每個通道獨立處理。

注意
  • 函式文字ID為 "org.opencv.imgproc.filters.morphologyEx"
  • 迭代次數是腐蝕或膨脹操作將應用的次數。例如,一個具有兩次迭代的開運算(MORPH_OPEN)等價於連續應用:腐蝕 -> 腐蝕 -> 膨脹 -> 膨脹(而不是腐蝕 -> 膨脹 -> 腐蝕 -> 膨脹)。
引數
src輸入影像。
op形態學操作的型別,參見 MorphTypes
kernel結構元素。可以使用 getStructuringElement 建立。
anchor錨點在元素中的位置。負值表示錨點位於核的中心。
iterations腐蝕和膨脹操作應用的次數。
borderType畫素外推方法,參見 BorderTypes。不支援 BORDER_WRAP
borderValue常量邊界情況下的邊界值。預設值具有特殊含義。
另請參見
dilate, erode, getStructuringElement

◆ sepFilter()

GMat cv::gapi::sepFilter ( const GMat & src,
int ddepth,
const Mat & kernelX,
const Mat & kernelY,
const Point & anchor,
const Scalar & delta,
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.sepFilter(src, ddepth, kernelX, kernelY, anchor, delta[, borderType[, borderValue]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

對矩陣(影像)應用可分離線性濾波器。

該函式對矩陣應用可分離線性濾鏡。即,首先,src 的每一行都用一維核 kernelX 進行濾波。然後,結果的每一列都用一維核 kernelY 進行濾波。最終結果被返回。

支援的矩陣資料型別為 CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1。輸出影像必須與輸入影像具有相同的型別、大小和通道數。

注意
  • 在浮點計算中,如果硬體支援,則進行四捨五入到最近的偶數(如果不支援,則四捨五入到最近的值)。
  • 函式文字ID為 "org.opencv.imgproc.filters.sepfilter"
引數
src源影像。
ddepth目標影像的期望深度(支援 src.depth() 和 ddepth 的以下組合
 src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
 src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
 src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
 src.depth() = CV_64F, ddepth = -1/CV_64F

當 ddepth=-1 時,輸出影像將與源影像具有相同的深度)

引數
kernelX用於過濾每一行的係數。
kernelY用於過濾每一列的係數。
anchor錨點在核內的位置。預設值 \((-1,-1)\) 表示錨點位於核的中心。
delta在儲存到結果中之前新增到濾波結果中的值。
borderType畫素外推法,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
boxFilter, gaussianBlur, medianBlur

◆ Sobel()

GMat cv::gapi::Sobel ( const GMat & src,
int ddepth,
int dx,
int dy,
int ksize = 3,
double scale = 1,
double delta = 0,
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.Sobel(src, ddepth, dx, dy[, ksize[, scale[, delta[, borderType[, borderValue]]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用擴充套件Sobel運算元計算一階、二階、三階或混合影像導數。

除了一個特例之外,所有情況下都使用 \(\texttt{ksize} \times \texttt{ksize}\) 可分離核來計算導數。當 \(\texttt{ksize = 1}\) 時,使用 \(3 \times 1\) 或 \(1 \times 3\) 核(即不進行高斯平滑)。ksize = 1 只能用於一階或二階 x 或 y 導數。

還有一個特殊值 ksize = FILTER_SCHARR (-1),它對應於 \(3\times3\) Scharr 濾鏡,這可能比 \(3\times3\) Sobel 濾鏡提供更準確的結果。Scharr 孔徑是

\[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\]

用於 x 導數,或轉置用於 y 導數。

該函式透過與適當的核進行卷積來計算影像導數

\[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\]

Sobel 運算元結合了高斯平滑和微分,因此結果或多或少地具有抗噪性。最常見的情況是,該函式以 (xorder = 1, yorder = 0, ksize = 3) 或 (xorder = 0, yorder = 1, ksize = 3) 呼叫,以計算一階 x 或 y 影像導數。第一種情況對應於一個核:

\[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\]

第二種情況對應於以下核

\[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\]

注意
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.sobel"
引數
src輸入影像。
ddepth輸出影像深度,參見 組合;對於8位輸入影像,它將導致截斷的導數。
dx導數 x 的階數。
dy導數 y 的階數。
ksize擴充套件 Sobel 核的大小;必須是奇數。
scale計算所得導數值的可選比例因子;預設情況下不應用縮放(詳見 cv::getDerivKernels)。
delta可選的 delta 值,在將結果儲存到 dst 之前新增到結果中。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
filter2D, gaussianBlur, cartToPolar

◆ SobelXY()

std::tuple< GMat, GMat > cv::gapi::SobelXY ( const GMat & src,
int ddepth,
int order,
int ksize = 3,
double scale = 1,
double delta = 0,
int borderType = BORDER_DEFAULT,
const Scalar & borderValue = Scalar(0) )
Python
cv.gapi.SobelXY(src, ddepth, order[, ksize[, scale[, delta[, borderType[, borderValue]]]]]) -> retval

#include <opencv2/gapi/imgproc.hpp>

使用擴充套件Sobel運算元計算一階、二階、三階或混合影像導數。

除了一個特例之外,所有情況下都使用 \(\texttt{ksize} \times \texttt{ksize}\) 可分離核來計算導數。當 \(\texttt{ksize = 1}\) 時,使用 \(3 \times 1\) 或 \(1 \times 3\) 核(即不進行高斯平滑)。ksize = 1 只能用於一階或二階 x 或 y 導數。

還有一個特殊值 ksize = FILTER_SCHARR (-1),它對應於 \(3\times3\) Scharr 濾鏡,這可能比 \(3\times3\) Sobel 濾鏡提供更準確的結果。Scharr 孔徑是

\[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\]

用於 x 導數,或轉置用於 y 導數。

該函式透過與適當的核進行卷積來計算影像導數

\[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\]

Sobel 運算元結合了高斯平滑和微分,因此結果或多或少地具有抗噪性。最常見的情況是,該函式以 (xorder = 1, yorder = 0, ksize = 3) 或 (xorder = 0, yorder = 1, ksize = 3) 呼叫,以計算一階 x 或 y 影像導數。第一種情況對應於一個核:

\[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\]

第二種情況對應於以下核

\[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\]

注意
  • 返回的第一個矩陣對應於 dx 導數,第二個對應於 dy。
  • 如果硬體支援,則進行四捨五入到最近的偶數;如果不支援,則四捨五入到最近的整數。
  • 函式文字ID為 "org.opencv.imgproc.filters.sobelxy"
引數
src輸入影像。
ddepth輸出影像深度,參見 組合;對於8位輸入影像,它將導致截斷的導數。
order導數的階數。
ksize擴充套件 Sobel 核的大小;必須是奇數。
scale計算所得導數值的可選比例因子;預設情況下不應用縮放(詳見 cv::getDerivKernels)。
delta可選的 delta 值,在將結果儲存到 dst 之前新增到結果中。
borderType畫素外推方法,參見 cv::BorderTypes
borderValue常量邊界型別情況下的邊界值
另請參見
filter2D, gaussianBlur, cartToPolar