-
畳み込みは数学的な概念であり、画像処理の操作です。画像の各ピクセルに対するカーネル(フィルター、畳み込みカーネル、演算子)の操作です。
- カーネルは本質的に固定サイズの小さなマトリックスであり、中心点はアンカーポイントであり、これは画像の海に固定することに相当します---->操作、つまりアンカーポイント
- 畳み込みのしくみ
- カーネルはピクセル配列に配置され、アンカーポイント周辺のカバレッジピクセルの積が計算されてから合計され、アンカーポイントカバレッジの下のピクセル値が置き換えられます。つまり、畳み込み処理です。
-
合計= 8x1 + 6x1 + 6x1 + 2x1 + 8x1 + 6x1 + 2x1 + 2x1 + 8x1
新しいピクセル=合計/(m * n)
-
畳み込み演算には2つのコアがあり、1つはカーネルの設計であり、もう1つは演算子がピクセルをトラバースする方法です。
-
一般に、次のようないくつかの古典的な演算子があります。
-
- カスタムオペレーター
- 小さな行列を作成することです。マットを使用して作成できることを学びました。
int main(int argc, char ** argv) { Mat src, gray, bin, dst; src = imread("C:\\Users\\xujin\\Desktop\\test1.JPG"); if (!src.data) { cout << "no image"; return -1; } namedWindow("src_image", WINDOW_AUTOSIZE); imshow("src_image", src); Mat dst_x, dst_y; Mat dstSobel_x, dstSobel_y, dstLap; src.copyTo(dst_x); src.copyTo(dst_y); src.copyTo(dstSobel_x); src.copyTo(dstSobel_y); src.copyTo(dstLap); Mat kernel_x = (Mat_<int>(2, 2) << 1, 0, 0, -1); Mat kernel_y = (Mat_<int>(2, 2) << 0,-1,-1,0); Mat kernelSobel_x = (Mat_<int>(3, 3) << -1, 0, -1, -2, 0, -2, -1, 0, -1); Mat kernelSobel_y = (Mat_<int>(3, 3) << -1,-2,-1, 0, 0, 0, 1, 2, 1); Mat kernelLap = (Mat_<int>(2, 2) << 0, -1, 0, -1, -4, -1, 0, -1, 0); filter2D(src, dst_x,-1, kernel_x, Point(-1, -1)); filter2D(src, dst_y, -1, kernel_x, Point(-1, -1)); //filter2D()是进行2D卷积操作的函数, 卷积核是一个小型矩阵,卷积核是设计核心 filter2D(src, dst_y, -1, kernelSobel_x, Point(-1, -1)); filter2D(src, dst_y, -1, kernelSobel_y, Point(-1, -1)); filter2D(src, dst_y, -1, kernelLap, Point(-1, -1)); namedWindow("dst_x_image", WINDOW_AUTOSIZE); imshow("dst_x_image", dst_x); namedWindow("dst_y_image", WINDOW_AUTOSIZE); imshow("dst_y_image", dst_y); namedWindow("dstSobel_x_image", WINDOW_AUTOSIZE); imshow("dstSobel_x_image", dstSobel_x); namedWindow("dstSobel_y_image", WINDOW_AUTOSIZE); imshow("dstSobel_y_image", dstSobel_y); namedWindow("dstLap_image", WINDOW_AUTOSIZE); imshow("dstLap_image", dstLap); waitKey(0); return 0; }
- 例如Matカーネル=(Mat_ <double>(3,3)<<-1,0、-1、-2,0,2、-1,0,1);
- 小さな行列を作成することです。マットを使用して作成できることを学びました。
- 畳み込み演算方法
- API:filter2D(src、dst、depth、kernel、anchor、delta);
- パラメータ(元の画像、出力画像、画像の深さ、演算子、アンカーポイント、デルタ);
- API:filter2D(src、dst、depth、kernel、anchor、delta);
-
- カーネルは本質的に固定サイズの小さなマトリックスであり、中心点はアンカーポイントであり、これは画像の海に固定することに相当します---->操作、つまりアンカーポイント
Opencv3 C ++ VS2017スタディノート12畳み込みおよび畳み込み演算子
おすすめ
転載: blog.csdn.net/Mrsherlock_/article/details/104551325
おすすめ
ランキング