hu矩為描述整體影像特征的一種方法,零階矩表示它的總質量;一階矩表示它的質心;二階矩又叫慣性矩,表示影像的大小和方向,
通過計算普通矩可以知道影像的重心坐標、形狀方向等;
Mat imgSrc = imread("lena.jpg", IMREAD_GRAYSCALE);
threshold(imgSrc, imgSrc, 50, 255, THRESH_BINARY);
Moments mom = moments(imgSrc, false);// Calculate Moments
double huMoments0[7];
double huMoments[7];
HuMoments(mom, huMoments0);// Calculate Hu Moments
for (int i = 0; i < 7; i++)
{
double dbValue = copysign(1.0, huMoments0[i]);
huMoments[i] = -1 * dbValue * log10(abs(huMoments0[i]));
}
vector<vector<Point>> contour;
findContours(imgSrc, contour, RETR_CCOMP, CHAIN_APPROX_SIMPLE);
double dbValue = matchShapes(contour, contour, CONTOURS_MATCH_I1, 0);
論文:Visual pattern recognition by moment invariants
https://zhuanlan.zhihu.com/p/117344473
https://www.jianshu.com/p/3cb0b97da76e
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/139260.html
標籤:其他
上一篇:C++基礎知識易錯點總結
