[英]OpenCV: L1 normalization of descriptor matrix
I'm trying to implement SIFTRoot in C++ following this article.我想用C来实现SIFTRoot ++下面这个文章。
In particular:特别是:
# apply the Hellinger kernel by first L1-normalizing and taking the
# square-root
descs /= (descs.sum(axis=1, keepdims=True) + eps)
descs = np.sqrt(descs)
My question are:我的问题是:
The SIFT descriptor is basically a histogram, so it shouldn't have negative values. SIFT 描述符基本上是一个直方图,所以它不应该有负值。 I don't think there exists a single function in OpenCV that does what you want to achieve.我认为 OpenCV 中不存在可以实现您想要实现的功能的单一功能。 But it's not too hard to come up with a few lines that do the job但是想出几行来完成这项工作并不难
// For each row
for (int i = 0; i < descs.rows; ++i) {
// Perform L1 normalization
cv::normalize(descs.row(i), descs.row(i), 1.0, 0.0, cv::NORM_L1);
}
// Perform sqrt on the whole descriptor matrix
cv::sqrt(descs, descs);
I don't know exactly how OpenCV deals with zero sum in L1 normalization.我不知道 OpenCV 如何处理 L1 归一化中的零和。 You can replace cv::normalize
with descs.rows(i) /= (cv::norm(descs.rows(i), cv::NORM_L1) + eps)
if the above code generates NaN.如果上述代码生成 NaN,您可以将cv::normalize
替换为descs.rows(i) /= (cv::norm(descs.rows(i), cv::NORM_L1) + eps)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.