Faster way to extract patches from images?

前端 未结 2 1322
日久生厌
日久生厌 2021-01-14 02:26

I am trying to extract patches of fixed size centered at some given position (x,y). The code is given below-

for i,j in zip(indices[0],indices[1]):
    patch         


        
2条回答
  •  囚心锁ツ
    2021-01-14 03:26

    Using scikit-learn:

    from sklearn.feature_extraction.image import extract_patches
    
    all_patches = extract_patches(x, patch_size)
    
    upper_left = indices - patch_size // 2
    patches = all_patches[upper_left[0], upper_left[1]]
    

    A similar function can be found in scikit-image: view_as_windows.

提交回复
热议问题