• + 0 comments

    DON'T UNDERSTAND WHY RUNTIME ERROR, MY PROGRAM IS IN PYTHON3

                    
    import cv2
    import numpy as np
    
    im = np.array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  ],
                    [ 0, 1, 1, 1, 1, 1, 1, 1, 0, 0,  ],
                    [ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0,  ],
                    [ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0,  ],
                    [ 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,  ],
                    [ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0,  ],
                    [ 0, 0, 0, 1, 1, 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,  ]], dtype = np.uint8)
    
    kernel = np.ones((3,3), dtype = np.uint8)
    
    
    img_dilation = cv2.dilate(im, kernel, iterations=1) 
    
    print(int(np.sum((img_dilation == 1))))