I wrote the sliding wing in creation.

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)

Recommended Posts

I wrote the sliding wing in creation.
I wrote the queue in Python
I wrote the stack in Python
I wrote the selection sort in C
I wrote the hexagonal architecture in go language
I wrote python in Japanese
I wrote the basic operation of Seaborn in Jupyter Lab
I wrote an empty directory automatic creation script in Python
I wrote it in Go to understand the SOLID principle
I wrote the basic operation of Numpy in Jupyter Lab.
I wrote a script that splits the image in two
I got lost in the maze
I participated in the ISUCON10 qualifying!
I wrote Fizz Buzz in Python
I wrote Gray Scale in Pytorch
I wrote the code to write the code of Brainf * ck in python
I can't get the element in Selenium!
I wrote the code for Gibbs sampling
A memo that I wrote a quicksort in Python
[Fundamental Information Technology Engineer Examination] I wrote the algorithm of Euclidean algorithm in Python.
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
I wrote a class in Python3 and Java
I wrote matplotlib
I wrote "Introduction to Effect Verification" in Python
Note that I understand the least squares algorithm. And I wrote it in Python.
I can't enter characters in the text area! ?? !! ?? !! !! ??
I wrote a PyPI module that extends the parameter style in Python's sqlite3 module
I wrote a design pattern in kotlin Prototype
I implemented the inverse gamma function in python
I wrote a Japanese parser in Japanese using pyparsing.
I checked the calendar deleted in Qiita Advent Calendar 2016
I implemented Human In The Loop ― Part ① Dashboard ―
I want to display the progress in Python!
I tried to graph the packages installed in Python
I wrote a design pattern in kotlin Singleton edition
I wrote a design pattern in kotlin Adapter edition
I want to write in Python! (3) Utilize the mock
[Note] I can't call the installed module in jupyter
I wrote a design pattern in kotlin Template edition
What I learned by participating in the ISUCON10 qualifying
I want to use the R dataset in python
I can't use the darknet command in Google Colaboratory!
I wrote you to watch the signal with Go
I counted the grains
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
I checked the Python package pre-installed in Google Cloud Dataflow
I wrote the code for Japanese sentence generation with DeZero
I participated in the translation activity of Django official documents
I tried the accuracy of three Stirling's approximations in python
I tried the super-resolution algorithm "PULSE" in a Windows environment
Mezzanine introduction memo that I got stuck in the flow
I tried to summarize the code often used in Pandas
I tried to illustrate the time and time in C language
I tried programming the chi-square test in Python and Java.
I just wrote the original material for the python sample code
I wrote a script to get a popular site in Japan
I tried to implement the mail sending function in Python
I can't log in to the admin page with Django3
I wrote a script to combine the divided ts files
I want to make the Dictionary type in the List unique