用法:
skimage.feature.haar_like_feature(int_image, r, c, width, height, feature_type=None, feature_coord=None)
計算積分圖像感興趣區域 (ROI) 的Haar-like 特征。
Haar-like 特征已成功用於圖像分類和對象檢測[1]。它已用於[2]中提出的實時人臉檢測算法。
- int_image:(M, N) ndarray
需要計算特征的積分圖像。
- r:int
檢測窗口左上角的Row-coordinate。
- c:int
檢測窗口左上角的Column-coordinate。
- width:int
檢測窗口的寬度。
- height:int
檢測窗口的高度。
- feature_type:str 或 str 列表或無,可選
要考慮的特征類型:
- ‘type-2-x’:沿 x 軸變化的 2 個矩形;
- ‘type-2-y’:沿 y 軸變化的 2 個矩形;
- ‘type-3-x’:沿 x 軸變化的 3 個矩形;
- ‘type-3-y’:沿 y 軸變化的 3 個矩形;
- ‘type-4’:沿 x 和 y 軸變化的 4 個矩形。
默認情況下,所有特征都被提取。
如果與feature_coord一起使用,它應該對應於每個關聯坐標特征的特征類型。
- feature_coord:元組列表的 ndarray 或無,可選
要提取的坐標數組。當您隻想重新計算特征的子集時,這很有用。在這種情況下feature_type需要是一個包含每個特征類型的數組,由返回skimage.feature.haar_like_feature_coord.默認情況下,計算所有坐標。
- haar_features:(n_features,) int 的 ndarray 或浮點數
產生Haar-like 特征。每個值等於正負矩形之和的減法。數據類型取決於int_image的數據類型:當int_image的數據類型為uint或int時為int,當int_image的數據類型為float時為float。
參數:
返回:
注意:
並行提取這些特征時,請注意後端的選擇(即多處理與線程)將對性能產生影響。經驗法則如下:在為圖像中所有可能的 ROI 提取特征時使用多處理;在為有限數量的 ROI 提取特定位置的特征時使用線程。參考例子使用Haar-like特征說明符進行人臉分類以獲得更多見解。
參考:
- 1
- 2
Oren, M., Papageorgiou, C., Sinha, P., Osuna, E., & Poggio, T. (1997, June). Pedestrian detection using wavelet templates. In Computer Vision and Pattern Recognition, 1997. Proceedings., 1997 IEEE Computer Society Conference on (pp. 193-199). IEEE. http://tinyurl.com/y6ulxfta DOI:10.1109/CVPR.1997.609319
- 3
Viola, Paul, and Michael J. Jones. “Robust real-time face detection.” International journal of computer vision 57.2 (2004): 137-154. https://www.merl.com/publications/docs/TR2004-043.pdf DOI:10.1109/CVPR.2001.990517
例子:
>>> import numpy as np >>> from skimage.transform import integral_image >>> from skimage.feature import haar_like_feature >>> img = np.ones((5, 5), dtype=np.uint8) >>> img_ii = integral_image(img) >>> feature = haar_like_feature(img_ii, 0, 0, 5, 5, 'type-3-x') >>> feature array([-1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -1, -2, -3, -4, -1, -2, -3, -4, -1, -2, -3, -1, -2, -3, -1, -2, -3, -1, -2, -1, -2, -1, -2, -1, -1, -1])
您可以計算一些預先計算的坐標的特征。
>>> from skimage.feature import haar_like_feature_coord >>> feature_coord, feature_type = zip( ... *[haar_like_feature_coord(5, 5, feat_t) ... for feat_t in ('type-2-x', 'type-3-x')]) >>> # only select one feature over two >>> feature_coord = np.concatenate([x[::2] for x in feature_coord]) >>> feature_type = np.concatenate([x[::2] for x in feature_type]) >>> feature = haar_like_feature(img_ii, 0, 0, 5, 5, ... feature_type=feature_type, ... feature_coord=feature_coord) >>> feature array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -3, -5, -2, -4, -1, -3, -5, -2, -4, -2, -4, -2, -4, -2, -1, -3, -2, -1, -1, -1, -1, -1])
相關用法
- Python skimage.feature.haar_like_feature_coord用法及代碼示例
- Python skimage.feature.hessian_matrix用法及代碼示例
- Python skimage.feature.hessian_matrix_eigvals用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
- Python skimage.feature.blob_dog用法及代碼示例
- Python skimage.feature.graycoprops用法及代碼示例
- Python skimage.feature.corner_orientations用法及代碼示例
- Python skimage.feature.structure_tensor用法及代碼示例
- Python skimage.feature.ORB用法及代碼示例
- Python skimage.feature.corner_subpix用法及代碼示例
- Python skimage.feature.canny用法及代碼示例
- Python skimage.feature.peak_local_max用法及代碼示例
- Python skimage.feature.CENSURE用法及代碼示例
- Python skimage.feature.corner_foerstner用法及代碼示例
- Python skimage.feature.corner_harris用法及代碼示例
- Python skimage.feature.corner_fast用法及代碼示例
- Python skimage.feature.BRIEF用法及代碼示例
- Python skimage.feature.SIFT用法及代碼示例
- Python skimage.feature.structure_tensor_eigvals用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.feature.haar_like_feature。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。