Ask Your Question

findcontours mystery unsupported format

asked 2020-11-09 16:59:11 -0500

BStrum gravatar image

updated 2020-11-09 17:01:24 -0500

I have read the post on the issue and am still at a loss.

I have a processing pipeline color image > greyscale > laplacian

    **depth = cv2.CV_16S
    kernel_size = 3
    Lap_Img = cv2.Laplacian(gray,depth,ksize=kernel_size)**

Then dilation 10X erosion 10X

    **dilation = cv2.dilate(Lap_Img, kernel, iterations=10)   # Dilate X10
    erosion = cv2.erode(dilation, kernel, iterations=10)    # Erode  X10**

Now I do a binary threshold:

    **ret, th1 = cv2.threshold(erosion, Thresh, 255, cv2.THRESH_BINARY)**

and how I want to find the large contours and create binary mask ret, th1 = cv2.threshold(erosion, Thresh, 255, cv2.THRESH_BINARY)

An here is where get the error Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'

I'm at a loss here, please advise.


edit retag flag offensive close merge delete


What is constant for THRESH?

supra56 gravatar imagesupra56 ( 2020-11-10 03:51:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-11-10 00:56:35 -0500

mvuori gravatar image

Well, you are passing that function a 16 bit image, while it tells you that it only accepts 8 or 32 bits. So, after laplacian, you need to convert the image to 8 bits, just like in the example code, before imshow:

edit flag offensive delete link more


Thanks! I'll give it a try and post the results.

BStrum gravatar imageBStrum ( 2020-11-10 10:06:08 -0500 )edit

This did the trick, Thanks!

BStrum gravatar imageBStrum ( 2020-11-10 15:41:24 -0500 )edit

Question Tools

1 follower


Asked: 2020-11-09 16:59:11 -0500

Seen: 2,123 times

Last updated: Nov 10 '20