GrayHistogramComputer.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:imgpedia 作者: scferrada 项目源码 文件源码
def compute(self, frame):
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        frameH, frameW = frame.shape
        descriptor = []
        for row in range(self.rows):
            for col in range(self.cols):
                mask = np.zeros_like(frame)
                mask[((frameH/self.rows)*row):((frameH/self.rows)*(row+1)),(frameW/self.cols)*col:((frameW/self.cols)*(col+1))] = 1
                hist = cv2.calcHist([frame], self.channel, mask, [self.bins], self.range)
                hist = cv2.normalize(hist, None)
                descriptor.append(hist)
        return np.concatenate([x for x in descriptor])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号