I am recently working on a project where in I have extracted some features regarding an image, and want to find if there are any similarities between two images using those features. Here are the list of features that I have extracted:
我最近正在开展一个项目,在这个项目中,我已经提取了一些关于图像的特征,并希望找到使用这些特征的两个图像之间是否有任何相似之处。以下是我提取的功能列表:
- Aspect ratio (width/height)
- Normalised area (Cropped roi's area to input image area)
- Centre of the cropped image
and other features from a single image
宽高比(宽/高)
标准化区域(裁剪roi区域到输入图像区域)
裁剪图像的中心和单个图像的其他特征
Now, I want to feed these values into a vector, and use that vector to find cosine similarity. In Short, use such vector from two images, and find the similarity between them. I know how cross product of two vectors works, but
I want help in storing these images into vector and usage of the vector. Any suggestions would be deeply appreciated.
现在,我想将这些值提供给向量,并使用该向量来查找余弦相似度。简而言之,从两个图像中使用这样的矢量,并找出它们之间的相似性。我知道两个向量的交叉产物是如何工作的,但是我想帮助将这些图像存储到向量和向量的使用中。任何建议都将深表感谢。
1 个解决方案
#1
oh, not too difficult.
哦,不是太难。
step 1: fill your feature(Mat) with numbers, one after the other:
第1步:用数字填充你的功能(Mat),一个接一个:
Mat feature; // you could use a std::vector, too, but cv::Mat has the
// handy dot-product used below already built in.
feature.push_back(aspect_ratio);
feature.push_back(area);
feature.push_back(center.x);
feature.push_back(center.y);
feature.push_back(more_stuff);
...
step 2: to compare those features, use the cosine norm :
第2步:比较这些功能,使用余弦规范:
Mat feature_a, feature_b; // composed like above
double ab = feature_a.dot(feature_b);
double aa = feature_a.dot(feature_a);
double bb = feature_b.dot(feature_b);
return -ab / sqrt(aa*bb);
#1
oh, not too difficult.
哦,不是太难。
step 1: fill your feature(Mat) with numbers, one after the other:
第1步:用数字填充你的功能(Mat),一个接一个:
Mat feature; // you could use a std::vector, too, but cv::Mat has the
// handy dot-product used below already built in.
feature.push_back(aspect_ratio);
feature.push_back(area);
feature.push_back(center.x);
feature.push_back(center.y);
feature.push_back(more_stuff);
...
step 2: to compare those features, use the cosine norm :
第2步:比较这些功能,使用余弦规范:
Mat feature_a, feature_b; // composed like above
double ab = feature_a.dot(feature_b);
double aa = feature_a.dot(feature_a);
double bb = feature_b.dot(feature_b);
return -ab / sqrt(aa*bb);