Dima Lituiev
Dima Lituiev

Reputation: 13116

What is expected format for opencv morphologyEx(..., borderValue) argument?

I would like to pad my grayscale image with white border for purpose of morphological close in opencv (in Python). Documentation does not really tell what the function needs. I have been trying following two examples to no avail:

smooth_mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel, 
                               borderValue=mask.max())

smooth_mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel, 
                               borderValue=np.array([mask.max()]))

Error:

TypeError: Scalar value for argument 'borderValue' is not numeric

Upvotes: 1

Views: 1000

Answers (1)

Dima Lituiev
Dima Lituiev

Reputation: 13116

It turns out to be plain scalar python int that solved the problem, not np.uint8 as in the input image.

Upvotes: 1

Related Questions