2 Star 1 Fork 1

mayanhui/smoke_recognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
feature_RGBspace.py 1018 Bytes
一键复制 编辑 原始数据 按行查看 历史
lancezhange 提交于 2015-12-08 21:50 . first commit
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: lancezhange
# @Date: 2015-08-12 14:47:33
# @Last Modified by: lancezhange
# @Last Modified time: 2015-08-21 11:23:14
from __future__ import division
import numpy as np
def getFeature(image, blocks=5):
'''Given an cv2 image object it returns its feature vector.
Args:
image (ndarray): image array
blocks (int, optional): number of block to subdivide the RGB space into.
Returns:
numpy array
'''
feature = np.zeros(blocks*blocks*blocks)
width, height, channel = image.shape
pixel_count = width*height
r = ((image[:, :, 2].reshape(pixel_count, 1)) / (256/blocks)).astype("int")
g = ((image[:, :, 1].reshape(pixel_count, 1)) / (256/blocks)).astype("int")
b = ((image[:, :, 0].reshape(pixel_count, 1)) / (256/blocks)).astype("int")
result = r + g*blocks + b*blocks*blocks
unique, counts = np.unique(result, return_counts=True)
feature[unique] = counts
return feature/(pixel_count)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/TimVerion/smoke_recognition.git
git@gitee.com:TimVerion/smoke_recognition.git
TimVerion
smoke_recognition
smoke_recognition
master

搜索帮助