聯系我們 - 廣告服務 - 聯系電話:
您的當前位置: > 關注 > > 正文

天天看熱訊:【計算】邊緣水平邊緣豎直邊緣計算 Robert詳解

來源:CSDN 時間:2023-03-02 09:43:35

目錄

計算

邊緣


(資料圖片僅供參考)

水平邊緣

豎直邊緣

計算

Mat src = (Mat_(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9);//X方向—Robert算子Mat imgx;Mat kernel_x = (Mat_(2, 2) << 1, 0, 0, -1);filter2D(src, imgx, -1, kernel_x, Point(-1, -1), 0, 0);Mat imgy;//Y方向—Robert算子Mat kernel_y = (Mat_(2, 2) << 0, 1, -1, 0);filter2D(src, imgy, -1, kernel_y, Point(-1, -1), 0, 0);

src                                                  kernel_x                                    kernel_y

imgx                                                      img_y

image_x值計算:                                                             image_y值計算:

image_x(0, 0) = 1 * 0 + 0 * 0 + 0 * 0 + (-1) * 1 = -1         image_y(0, 0) = 0 * 0 + 1 * 0 + (-1) * 0 +  0 * 1 =0

image_x(0, 1) = 1 * 0 + 0 * 0 + 0 * 1 + (-1) * 2 = -2         image_y(0, 1) = 0 * 0 + 1 * 0 + (-1) * 1 + 0 * 2 = -1

...                                                                                     ...

image_x(1, 1) = 1 * 1 + 0 * 2 + 0 * 4 + (-1) * 5 = -4         image_y(1, 1) = 0 * 1 + 1 * 2 + (-1) * 4 + 0 * 5 = -2

...                                                                                     ...

image_x(2, 2) = 1 * 5 + 0 * 6 + 0 * 8 + (-1) * 9 = -4         image_y(2, 2) = 0 * 5 + 1 * 6 + (-1) * 8 + 0 * 9 = -2

邊緣

Mat src = (Mat_(5, 5) << 1, 2, 3, 4, 5,                         2, 3, 6, 5, 7,                        25, 35, 45, 35, 55,                         7, 8, 9, 10, 11,                         7, 3, 6, 8, 11);//X方向—Robert算子Mat imgx;Mat kernel_x = (Mat_(2, 2) << 1, 0, 0, -1);filter2D(src, imgx, -1, kernel_x, Point(-1, -1), 0, 0);Mat imgy;//Y方向—Robert算子Mat kernel_y = (Mat_(2, 2) << 0, 1, -1, 0);filter2D(src, imgy, -1, kernel_y, Point(-1, -1), 0, 0);

水平邊緣

src

imgx                                                                                       imgy

豎直邊緣

Mat src = (Mat_(5, 5) << 1, 2, 3, 4, 5,                         2, 3, 6, 5, 7,                        25, 35, 45, 35, 55,                         7, 8, 9, 10, 11,                         7, 3, 6, 8, 11);Mat tsrc = src.t();//X方向—Robert算子Mat imgx;Mat kernel_x = (Mat_(2, 2) << 1, 0, 0, -1);filter2D(tsrc, imgx, -1, kernel_x, Point(-1, -1), 0, 0);Mat imgy;//Y方向—Robert算子Mat kernel_y = (Mat_(2, 2) << 0, 1, -1, 0);filter2D(tsrc, imgy, -1, kernel_y, Point(-1, -1), 0, 0);

tsrc

責任編輯:

標簽:

相關推薦:

精彩放送:

新聞聚焦
Top 岛国精品在线