title: Removing watermark out of an image using OpenCV
body: <p>First of all I have this image and I want to make an application that can detect images like it and remove the circle (watermark) from it.</p>
  
  <p><a href="https://i.stack.imgur.com/YZeOg.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/YZeOg.jpg" alt="image has a watermark"></a></p>
  
  <pre><code>int main(){
      Mat im1,im2,im3,gray,gray2,result;
  
      im2=imread(" (2).jpg");
      namedWindow("x",CV_WINDOW_FREERATIO);
      imshow("x",im2);
  
      //converting it to gray
      cvtColor(im2,gray,CV_BGR2GRAY);
      // creating a new image that will have the cropped ellipse
      Mat ElipseImg(im2.rows,im2.cols,CV_8UC1,Scalar(0,0,0));
  
      //detecting the largest circle
      GaussianBlur(gray,gray,Size(5,5),0);
      vector&lt;Vec3f&gt; circles;
      HoughCircles(gray,circles,CV_HOUGH_GRADIENT,1,gray.rows/8,100,100,100,0);
  
      uchar x;
      int measure=0;int id=0;
      for(int i=0;i&lt;circles.size();i++){
          if(cvRound(circles[i][2])&gt;measure &amp;&amp; cvRound(circles[i][2])&lt;1000){
              measure=cvRound(circles[i][2]);
              id=i;
          }
      }
  
  
      Point center(cvRound(circles[id][0]),cvRound(circles[id][1]));
      int radius=cvRound(circles[id][2]);
      circle(im2,center,3,Scalar(0,255,0),-1,8,0);
      circle(im2,center,radius,Scalar(0,255,0),2,8,0);
      ellipse(ElipseImg,center,Size(radius,radius),0,0,360,Scalar(255,255,255),-1,8);
      cout&lt;&lt;"center: "&lt;&lt;center&lt;&lt;" radius: "&lt;&lt;radius&lt;&lt;endl;
  
  
  
      Mat res;
      bitwise_and(gray,ElipseImg,result);
      namedWindow("bitwise and",CV_WINDOW_FREERATIO);
      imshow("bitwise and",result);
  
      // trying to estimate the Intensity  of the circle for the thresholding
      x=result.at&lt;uchar&gt;(cvRound(circles[id][0]+30),cvRound(circles[id][1]));
      cout&lt;&lt;(int)x;
  
      //thresholding the  output image
      threshold(ElipseImg,ElipseImg,(int)x-10,250,CV_THRESH_BINARY);
      namedWindow("threshold",CV_WINDOW_FREERATIO);
      imshow("threshold",ElipseImg);
  
      // making bitwise_or
      bitwise_or(gray,ElipseImg,res);
      namedWindow("bitwise or",CV_WINDOW_FREERATIO);
      imshow("bitwise or",res);
  
      waitKey(0);
  }
  </code></pre>
  
  <p>So far what I made is:</p>
  
  <ol>
  <li>I convert it to grayscale </li>
  <li>I detect the largest circle using Hough circles and then make a circle with same radius in a new image </li>
  <li>This new circle with the gray-scaled one using (<code>bitwise_and</code>) gives me an image with only that circle</li>
  <li>Threshold that new image</li>
  <li><code>bitwise_or</code> the result of the threshold</li>
  </ol>
  
  <p>My problem is that any black text on the curved white line inside this circle didn't appear. I tried to remove the color by using the pixel values instead of threshold, but the problem is the same.
  So any solutions or suggestions?</p>
  
  <p>These are the results:
  <a href="https://i.stack.imgur.com/eaaD4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eaaD4.png" alt="enter image description here"></a></p>