Watershed not optimal (C++ implementation)

asked 2014-10-14 11:05:05 -0500

amichaut gravatar image


I have implemented a Watershed algorithm on a test file. Here is my markers file: C:\fakepath\test_shape.002.jpg Here is my image file: C:\fakepath\test_shape.001.jpg And here is my output file: C:\fakepath\cell.tiff

As you can see the limit is not very accurate. Do you think there is something I can do? Here's my code:

  Mat markers(img.size(), CV_32S);
  markers = Scalar::all(0);
  for(int i=0; i<marker_contours.size(); ++i)
    drawContours(markers, marker_contours, i, Scalar::all(i+1), CV_FILLED, 8, vector<Vec4i>(),0,Point());
  Mat wshed_img = Mat::zeros(img.size(),CV_8UC3);
  // draw the watershed image
  for( int i = 0; i < markers.rows; i++ )
    for( int j = 0; j < markers.cols; j++ )
      int index = markers.at<int>(i,j);
      if( index == -1 )
        img.at<uchar>(i,j) = uchar(0);

Many thanks

edit retag flag offensive close merge delete


I am sorry, but I dont see any difference between the result and what you want to obtain

KansaiRobot gravatar imageKansaiRobot ( 2015-02-08 18:29:46 -0500 )edit