如何使用scikit图像函数功能计算所有类型的Haar类特征?这就是我尝试过的(一个计算2x类型所有功能的简单示例):
from skimage.feature import haar_like_feature
from skimage.transform import integral_image
img = np.array([[1, 2],
[1, 3]])
ii = integral_image(img)
features = haar_like_feature(ii, 0, 0, ii.shape[1], ii.shape[0], 'type-2-x')
print(features)
[1, 2]但是,我希望得到[1, 2, 3],因为我们还应该考虑覆盖整个图像的矩形特征,从而得到特征值(2 + 3) - (1 + 1) = 3。
我还查看了Viola的论文,它们有以下几个特性:
type-2-x: 43200
type-2-y: 43200
type-3-x: 27600
type-3-y: 27600
type-4: 20736
total: 162336(资料来源:Viola人脸检测算法分析)
但是,skimage.feature.haar_like_feature生成的特性的数量不同:
img = np.random.randint(0, 256, (24,24))
ii = integral_image(img)
total = 0
for feature_type in ['type-2-x', 'type-2-y', 'type-3-x', 'type-3-y', 'type-4']:
features = haar_like_feature(ii, 0, 0, ii.shape[1], ii.shape[0], feature_type)
print(f"{feature_type}: {len(features)}")
total += len(features)
print("\ntotal:", total)type-2-x: 43056
type-2-y: 43056
type-3-x: 27508
type-3-y: 27508
type-4: 20736
total: 161864因此,似乎在这个计算中缺少了472个特征。我做错了吗?应该将哪些参数传递给函数haar_like_feature()以获得所有特性?
更新:函数haar_like_feature https://github.com/scikit-image/scikit-image/issues/4818的实现似乎存在缺陷
发布于 2020-09-11 07:31:06
在这里,我只想分享:
出发地: img = np.array([1,2,1,3])
致: img = np.random.randint(0,256,(12,12))
尝试增加np.array()或图像size..to的输入大小,例如12x12。
https://stackoverflow.com/questions/62682760
复制相似问题