当前位置:网站首页>图像特征计算与表示——基于内容的图像检索
图像特征计算与表示——基于内容的图像检索
2022-06-29 17:46:00 【华为云】
| 1️⃣作业需求 |
|---|
| 2️⃣核心代码 |
|---|
# coding:utf-8def extract_features(image_path, vector_size=32): image = imageio.imread(image_path) try: # Using KAZE, cause SIFT, ORB and other was moved to additional module alg = cv2.KAZE_create() # Finding image keypoints # 寻找图像关键点 kps = alg.detect(image) # Getting first 32 of them. # 计算前32个 # Number of keypoints is varies depend on image size and color pallet # 关键点的数量取决于图像大小以及彩色调色板 # Sorting them based on keypoint response value(bigger is better) # 根据关键点的返回值进行排序(越大越好) kps = sorted(kps, key=lambda x: -x.response)[:vector_size] # computing descriptors vector # 计算描述符向量 kps, dsc = alg.compute(image, kps) # Flatten all of them in one big vector - our feature vector # 将其放在一个大的向量中,作为我们的特征向量 dsc = dsc.flatten() # Making descriptor of same size # 使描述符的大小一致 # Descriptor vector size is 64 # 描述符向量的大小为64 needed_size = (vector_size * 64) if dsc.size < needed_size: # if we have less the 32 descriptors then just adding zeros # at the end of our feature vector # 如果少于32个描述符,则在特征向量后面补零 dsc = np.concatenate([dsc, np.zeros(needed_size - dsc.size)]) except cv2.error as e: print('Error: ', e) return None return dsc| 3️⃣实验结果 |
|---|
我们从数据集中随意选取一张图片:
用鼠标框出图像中的一块区域:
然后回车会获取数据集中与框出的目标区域特征最相近的五张图片:
还会输出每张图片的匹配值,这里的匹配值就是计算目标区域的特征与数据库中的图片的余弦距离,如果想相似度更高,可以扩充数据集,使得特征更加适配:
| 实验源码+报告 |
|---|
边栏推荐
- Repair of JSON parsing errors in a collection
- 布隆过滤器:
- 软件快速交付真的需要以安全为代价吗?
- How to solve the 2003 error of MySQL in Linux
- Walk with love, educate and run poor families, and promote public welfare undertakings
- Industry application of smart city based on GIS 3D visualization
- Have you grasped the most frequently asked question in the interview about massive data processing?
- Force deduction daily question 06.29 add two numbers
- R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图
- sequential detector
猜你喜欢

剑桥大学教授:经常吃早餐害处多,很危险 - 知乎

Teach you how to install the latest version of mysql8.0 database on windows, nanny level teaching

育润多维发力慈善领域,勇抗企业公益大旗

2022春夏系列 KOREANO ESSENTIAL重塑时装生命力

Face recognition 4- research on Baidu commercial solutions

Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor

双亲委派机制

Visio annotation, annotation location

How MySQL queries character set codes of tables

What is the MySQL query view command
随机推荐
Createstore for Redux source code analysis
SRM系统是什么系统?如何应用SRM系统?
自定义HandlerInterceptor拦截器实现用户鉴权
mysql. What is the concept of sock
PCB frame drawing - ad19
【Try to Hack】Cookie和Session
0 basic self-study STM32 (wildfire) -- use register to light LED -- Explanation of GPIO function block diagram
第42期:MySQL 是否有必要多列分区
The R language uses the KAP function (kap.2.raters function) of epidisplay package to calculate the value of kappa statistics (total consistency, expected consistency), analyze the consistency of the
Bottom level internal skill cultivation
R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、使用exp函数和coef函数获取模型所有变量的事件密度比(Incidence Density Ratio,IDR)并解读
SRM系统可以为企业带来什么价值?
Li Kou today's question -535 Encryption and decryption of tinyurl
Teach you how to install the latest version of mysql8.0 database on windows, nanny level teaching
基于STM32F103ZET6库函数定时器中断实验
R语言dplyr包filter函数通过组合逻辑(与逻辑)过滤dataframe数据中的数据、其中一个字段的内容等于指定向量中的其中一个,并且另外一个字段值大于某一阈值
SSH协议学习笔记
双亲委派机制
R language uses user-defined functions to write deep learning linear activation functions and visualize linear activation functions
How to create and delete MySQL triggers