1

I want to perform an oversegmentation of image using watershed method. Reading documentation, I'd need to use findContour and drawContour function to create marker. How can I use that?

This is my current code,

import cv2
import numpy as np

im=cv2.imread('balls.jpg')
marker=np.zeros(im.shape[:2])
marker[::30,::30]=200
marker=np.int32(marker)

cv2.watershed(im,marker)
out=cv2.convertScaleAbs(marker)

cv2.namedWindow('Out')
cv2.imshow('Out', out)
cv2.waitKey()

P/S: There's another question on this, but they used other approach(based on foreground and background. I want to use contours instead).

This is my goal: produce an oversegmetnation of image:

enter image description here

Input image can be downloaded from here: http://decsai.ugr.es/~javier/denoise/peppers256.png

Dzung Nguyen
  • 3,794
  • 9
  • 48
  • 86
  • 1
    It will help if you post a sample image. – flowfree Apr 25 '13 at 02:19
  • 1
    try this : http://stackoverflow.com/questions/11294859/how-to-define-the-markers-for-watershed-in-opencv/11438165#11438165 – Abid Rahman K Apr 25 '13 at 05:48
  • Thanks for the link, but because I want to produce an oversegmentation, so the marker image can't be foreground and background. I tried to have the marks put evenly (marker[::30,::30]=200) but that does not produce any segmentation result. – Dzung Nguyen Apr 25 '13 at 15:28
  • Your example looks like intensity-based segmentation – GStav Mar 21 '16 at 11:00

0 Answers0