Ask Your Question
0

findcontours mystery unsupported format

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

BStrum gravatar image

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

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.

Thanks

edit retag flag offensive close merge delete

Comments

What is constant for THRESH?

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

1 answer

Sort by ยป oldest newest most voted
0

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

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: https://docs.opencv.org/3.4/d5/db5/tu...

edit flag offensive delete link more

Comments

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

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

This did the trick, Thanks!

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

Question Tools

1 follower

Stats

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

Seen: 6,961 times

Last updated: Nov 10 '20