title: Detecting small circles with OpenCV (bad image quality)
body: <p>I'm trying to detect the four dots you can see in the center of this picture:
  <img src="https://i.stack.imgur.com/tZqDR.png" alt="enter image description here">
  This one is converted to png, I actually use a ppm format (after conversion from raw output from the camera). The actual processed image is available <a href="http://student.agh.edu.pl/~grajewsk/img-000012.ppm" rel="noreferrer">here</a></p>
  
  <p>I'm new to opencv and therefore have a huge problem detecting those dots. Here's my so far best result:
  <img src="https://i.stack.imgur.com/rMcIh.png" alt="enter image description here"></p>
  
  <p>As you can see, I've detected 3 of the dots, but aside from that also lots of other things in the picture are recognized as circles.</p>
  
  <p>And here's the code:<br></p>
  
  <pre><code>    IplImage* img;
      if((img = cvLoadImage( "photos/img-000012.ppm", 1)) == 0 )
      {
          perror("cvLoadImage");
          return 1;
      }
      cvNamedWindow( "Image view", 1 );
      cvShowImage( "Image view", img );
  //  cvWaitKey(0);
  
      IplImage* gray = cvCreateImage( cvGetSize(img), 8, 1 ); // allocate a 1 channel byte image
      CvMemStorage* storage = cvCreateMemStorage(0);
      cvCvtColor( img, gray, CV_BGR2GRAY );
      cvShowImage( "Image view", gray );
  //  cvWaitKey(0);
  
      cvSmooth( gray, gray, CV_GAUSSIAN, 3, 3, 0, 0 );
      cvShowImage( "Image view", gray );
      cvWaitKey(0);
  
      CvSeq* circles = cvHoughCircles(gray, storage, CV_HOUGH_GRADIENT,
              4,      // inverse ratio of the accumulator resolution
              1,      // minimum distance between circle centres
              100,    // higher threshold value for Canny
              20,     // accumulator threshold for the circle centers; smaller-&gt;more false circles
              1,  // minimum radius
              10 );   // maximum radius
  
      printf("circles == %d\n", circles-&gt;total);
      int i;
      for (i = 0; i &lt; circles-&gt;total; i++) {
          float *p = (float*)cvGetSeqElem(circles, i);
          CvPoint center = cvPoint(cvRound(p[0]),cvRound(p[1]));
          CvScalar val = cvGet2D(gray, center.y, center.x);
          if (val.val[0] &lt; 1) continue;
          printf("%d %d %d\n", cvRound(p[0]),cvRound(p[1]), cvRound(p[2]));
          cvCircle(img,  center, cvRound(p[2]),             CV_RGB(0,255,0), 1, CV_AA, 0);
      }
      cvShowImage( "Image view", img );
      cvWaitKey(0);
  </code></pre>
  
  <p>Do you have any idea how to help that? I would be most grateful. I think it's quite easy for a human eye to spot the dots, so I hope I can detect them using a computer.</p>