[英]Matlab's diff in OpenCV
正如@beaker在評論中指出的,它是[-1 1]內核,這只是實現它的代碼
cv::Mat Kernely = (cv::Mat_<float>(2, 1) << -1, 1);
cv::Mat Kernelx = (cv::Mat_<float>(1, 2) << -1, 1);
cv::Mat dx, dy;
cv::filter2D(L, dy, -1, Kernely, cv::Point(-1, -1), 0.0, cv::BORDER_CONSTANT);
// Remove padding and take the abs of the output
dy = cv::Mat(dy, cv::Rect(0, 1, dy.cols, dy.rows - 1));
dy = cv::abs(dy);
cv::filter2D(L, dx, -1, Kernelx, cv::Point(-1, -1), 0.0, cv::BORDER_CONSTANT);
dx = cv::Mat(dx, cv::Rect(1, 0, dx.cols - 1, dx.rows));
dx = cv::abs(dx);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.