Skip to content

cannot process more than one images ? #6

@lizhengwei1992

Description

@lizhengwei1992

Hi, I find a strange phenomenon when I process more than one image like this:

img = cv2.imread('00003.png')
trimap = cv2.imread('00003_trimap.png')
alpha = knn_matte(img, trimap)

img = cv2.imread('donkey.png')
trimap = cv2.imread('donkeyTrimap.png')
alpha = knn_matte(img, trimap)    

at first image, everything is normal, I get the alpha map.
then, the process stops at the second image:

Traceback (most recent call last):
  File "knn_matting.py", line 88, in <module>
    main(args)
  File "knn_matting.py", line 75, in main
    alpha = knn_matte(img, trimap)
  File "knn_matting.py", line 39, in knn_matte
    D_script = scipy.sparse.diags(np.ravel(A.sum(axis=1)))
  File "/home/lzw/.local/lib/python3.5/site-packages/scipy/sparse/base.py", line 1015, in sum
    np.ones((n, 1), dtype=res_dtype))
  File "/home/lzw/.local/lib/python3.5/site-packages/numpy/matrixlib/defmatrix.py", line 68, in asmatrix
    return matrix(data, dtype=dtype, copy=False)
  File "/home/lzw/.local/lib/python3.5/site-packages/numpy/matrixlib/defmatrix.py", line 118, in __new__
    PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions