簡體   English   中英

Matlab在OpenCV中的差異

[英]Matlab's diff in OpenCV

我在OpenCV中搜索了與Matlab中的diff類似的函數,但沒有找到,
我實際上想在OpenCV中實現wls過濾器matlab的代碼

正如@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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM