Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It seems simple blur() with low kernel value works fine with your images. After blur just apply Threshold Binary Inverted with lower value.

  Mat src=imread("1.bmp",0);
  Mat dst,thr;
  blur( src, thr, Size( 5, 5 ), Point(-1,-1) );// blur with kernel(5X5)
  threshold(thr,thr,50,255,CV_THRESH_BINARY_INV);// Threshold binary inverted 
  src.copyTo(dst,thr); copy source image to destination by setting threshold as mask

For better result you may proceed with findcontour(),drawcontour(),minEnclosingCircle() on your threshold image to segment exactly circled image.

It seems simple blur() with low kernel value works fine with your images. After blur just apply Threshold Binary Inverted with lower value.

  Mat src=imread("1.bmp",0);
  Mat dst,thr;
  blur( src, thr, Size( 5, 5 ), Point(-1,-1) );// blur with kernel(5X5)
  threshold(thr,thr,50,255,CV_THRESH_BINARY_INV);// Threshold binary inverted 
  src.copyTo(dst,thr); copy source image to destination by setting threshold as mask

For better result you may proceed with findcontour(),drawcontour(),minEnclosingCircle() on your threshold image to segment exactly circled image.

Edit:

Using contour you can try below code

float radius=0;
Point2f center;  
vector< vector <Point> > contours; // Vector for storing contour
vector< Vec4i > hierarchy;
Mat mask(src.rows,src.cols,CV_8UC1,Scalar::all(0)); //create mask image

findContours( thr, contours, hierarchy,CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE ); 
minEnclosingCircle( contours[0], center, radius); //Here assumes  your image contains only one contour, if more than one contour use loop and consider largest contour
circle(mask,Point(center.x,center.y),radius,Scalar(255),-1,8,0);//Fill mask with region to be segment
//Copy using above mask
src.copyTo(dst,mask);

And here is the result i got for your image.

image description image description image description