img_func.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码
def splitimg(im_inp,n_row,n_col):
    #determine size of input image
    h_img, w_img = im_inp.shape[:2]
    #determine size of each cropped image
    h_row = h_img / num_rows
    w_col = w_img / num_cols
    #declare fragmented image matrix
    img_frag = np.empty((num_rows, num_cols, h_row, w_col), dtype=np.uint8)
    #fragments input image and put it into matrix
    for i in range(0, num_rows):
        h0 = h_row * i
        h1 = h_row * (i + 1)
        for j in range(0, num_cols):
            w0 = w_col * j
            w1 = w_col * (j + 1)
            img_frag[i, j] = im_inp[h0:h1, w0:w1]
            #uncomment following lines for debugging to show image
            # cv2.imshow('image1', img_frag[i, j])
            # cv2.waitKey(0)
            # cv2.destroyAllWindows()
    return img_frag
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号