• + 0 comments

    import numpy as np

    image = np.array([

    [0, 0, 1, 1, 0],

    [0, 0, 1, 1, 0],

    [0, 0, 1, 1, 0],

    [1, 1, 1, 1, 1]

    ])

    row = image.shape[0]

    column = image.shape[1]

    arr = np.copy(image)

    for i in range(row):

    for j in range(column):

    if i in [1,2]:

    # Check up and down

    if image[i-1,j] == 0 or image[i+1, j] == 0:

    arr[i,j] = 0

    else:

    arr[i,j] = 0

    for i in range(arr.shape[0]):

    line = ''

    for j in range(arr.shape[1]):

    line += str(arr[i][j])

    print(line)