当前位置:网站首页>Image feature computation and representation -- content based image retrieval
Image feature computation and representation -- content based image retrieval
2022-06-29 17:57:00 【Hua Weiyun】
1️⃣ Job requirements |
---|
2️⃣ Core code |
---|
# 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 # Find image keys kps = alg.detect(image) # Getting first 32 of them. # Before calculation 32 individual # Number of keypoints is varies depend on image size and color pallet # The number of keys depends on the image size and the color palette # Sorting them based on keypoint response value(bigger is better) # Sort according to the return value of the key ( The bigger the better ) kps = sorted(kps, key=lambda x: -x.response)[:vector_size] # computing descriptors vector # Compute descriptor vector kps, dsc = alg.compute(image, kps) # Flatten all of them in one big vector - our feature vector # Put it in a large vector , As our eigenvector dsc = dsc.flatten() # Making descriptor of same size # Make descriptors the same size # Descriptor vector size is 64 # The size of the descriptor vector is 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 # If less than 32 A descriptor , Then zero is added after the eigenvector dsc = np.concatenate([dsc, np.zeros(needed_size - dsc.size)]) except cv2.error as e: print('Error: ', e) return None return dsc
3️⃣ experimental result |
---|
We randomly select a picture from the dataset :
Frame an area in the image with the mouse :
Then press enter to obtain the five pictures in the data set that are closest to the characteristics of the framed target area :
The matching value of each picture will also be output , The matching value here is the cosine distance between the feature of the target area and the image in the database , If you want to be more similar , Data sets can be expanded , Make the features more suitable :
Experiment source code + The report |
---|
边栏推荐
- Let's start with a bug that was cheated by the app store
- What technology is an applet container? Can it help Internet of things enterprises break through the red sea?
- How QQ opens online customer service
- Matlab farthest point sampling (FPS)
- Prevent form resubmission based on annotations and interceptors
- Visual studio plug-in coderush officially released v22.1 -- visual tool for optimizing debugging
- 基于STM32F103ZET6库函数PWM输出实验
- js两个一维数组合并并去除相同项(整理)
- 如何使用B/S开发工具DevExtreme的图表控件 - 自定义轴位置?
- 力扣每日一题 06.29 两数相加
猜你喜欢
ISO 32000-2 international standard 7.7
Selenium file upload method
Parental delegation mechanism
SRM供应商协同管理系统功能介绍
双亲委派机制
Professor of Cambridge University: eating breakfast often is harmful and dangerous. - you know what
Detailed introduction and Simulation of bitmap
迈动互联中标大家保险集团
填充每个节点的下一个右侧节点指针[利用好每个点->尽可能降低时空复杂度]
selenium上传文件
随机推荐
reflex
Selenium key combination operation
Can MySQL views create indexes
从一个被应用商店坑了的BUG说起
小白月赛51 补题 E G F
Partial mock of static class of phpunit operation
一次采集JSON解析错误的修复
Set double click to run the jar file
图像特征计算与表示——基于内容的图像检索
Mysql database literacy, do you really know what a database is
基于STM32F103ZET6库函数独立看门狗(IWDG)实验
VB.Net读写NFC Ntag标签源码
第42期:MySQL 是否有必要多列分区
Sword finger offer 13 Robot range of motion (BFS)
lodash深拷贝使用
Web Scraping with Beautiful Soup for Data Scientist
Niuke small Bai monthly race 52 D ring insectivorous (feet +st table)
How to use the chart control of the b/s development tool devextreme - customize the axis position?
跨境独立站语言unicode转希伯来语
selenium 文件上传方法