Ask Your Question
0

problem using morphologyEx [closed]

asked 2018-08-25 01:45:58 -0600

updated 2018-08-25 02:45:02 -0600

berak gravatar image

I tried to use

close0 = cv2.morphologyEx(image, cv2.MORPH_CLOSE, mask, iterations = 1)

and I got this error:

error: OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\imgproc\src\morph.cpp:787: error: (-215) _kernel.type() == 0 in function cv::MorphFilter<struct cv::MaxOp<unsigned char>,struct cv::MorphIVec<struct cv::VMax8u> >::MorphFilter

what should I do?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by FarhaadZ
close date 2018-08-25 23:20:54.793021

Comments

it complains, that your kernel has the wrong type (should be 0, uchar).

so what is mask ? (also a misnomer)

berak gravatar imageberak ( 2018-08-25 02:48:04 -0600 )edit

mask is a 3 by 3 zero-matrix with only ones in the middle row.

FarhaadZ gravatar imageFarhaadZ ( 2018-08-25 03:18:15 -0600 )edit

and mask.dtype is ? (should be 0, np.uint8)

berak gravatar imageberak ( 2018-08-25 03:31:40 -0600 )edit

it returns: dtype('float64')

FarhaadZ gravatar imageFarhaadZ ( 2018-08-25 04:48:15 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2018-08-25 04:53:55 -0600

I add np.uint8 to the end of mask = np.zeros((3, 3)) and it worked! it is now: mask0 = np.zeros((3, 3), np.uint8)

edit flag offensive delete link more

Comments

great,you should close your question now

jsxyhelu gravatar imagejsxyhelu ( 2018-08-25 20:38:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-25 01:45:58 -0600

Seen: 4,525 times

Last updated: Aug 25 '18