Skip to content

Commit 72a45c1

Browse files
committed
create colored contours output
1 parent 59ad201 commit 72a45c1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

segMethod.py

+8
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ def cannyWatershed(inputfile):
372372

373373
cv.imshow("temp 2+3+4", temp_result)
374374

375+
temp_result_gray = cv.cvtColor(temp_result, cv.COLOR_RGB2GRAY)
376+
_, contours, hierarchy = cv.findContours(temp_result_gray, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_NONE)
377+
drawing = np.zeros(image.shape, dtype=np.uint8)
378+
for i in range(len(contours)):
379+
color = [rng.randint(0, 256), rng.randint(0, 256), rng.randint(0, 256)]
380+
drawing = cv.drawContours(drawing, contours, i, color, 1, 8)
381+
cv.imshow("drawing", drawing)
382+
375383
'''
376384
result_image_or = cv.bitwise_or(felzenszwalb_result, slic_result)
377385
result_image_or = cv.bitwise_or(result_image_or, quickshift_result)

0 commit comments

Comments
 (0)