LoginSignup
0
0

More than 3 years have passed since last update.

スライディングウィングを創造で書いた。

Posted at
img = np.array(range(100)).reshape([10,10])
img = np.zeros([100,100])
img[0:50,0:50] = 1

win_size = 2
def SlidingWindow(win_size,img):
  split_img = []
  yx = []
  for i in range(img.shape[0]-win_size+1):
    for j in range(img.shape[1]-win_size+1):
      split_img.append(img[i:i+win_size,j:j+win_size])
      yx.append([i,j])
  all = []
  for img_,yx_ in zip(split_img,yx):
    all = all + [(i+yx_[0],j+yx_[1]) for (i,j) in list(zip(*np.where(img_ == 1)))]
  return Counter(all)
SlidingWindow(4,img)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0