title: How to recognize the lightning on the picture?
body: <p>My task is recognition a lightning on the picture. I have chosen to use OpenCV. </p>
  
  <p>I'm using binary tresholding to get image like this. </p>
  
  <p>Original:</p>
  
  <p><img src="https://i.stack.imgur.com/FhyDR.png" alt="Image"> </p>
  
  <p>After binary thresholding:</p>
  
  <p><img src="https://i.stack.imgur.com/ITa3K.png" alt="Image"></p>
  
  <p>How now to determine whether there is lightning in the image? </p>
  
  <p>So, how to distinguish lightning on the image from other lines? For example</p>
  
  <p>on this image after binary tresholding i have got the following:
  <img src="https://i.stack.imgur.com/T725r.png" alt="Image"></p>
  
  <p>but if i just count the number of white pixels - i get a wrong answer.</p>
  
  <p>Main part of my code:</p>
  
  <pre><code>if ((Igray = cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE)) == 0) {
      return -1;
  }
  int block_size = atoi(argv[2]);
  double offset = (double)atof(argv[3]);
  
  Iat = cvCreateImage(cvSize(Igray -&gt; width, Igray -&gt; height), IPL_DEPTH_8U, 1);
  // treshold
  cvThreshold(Igray, Iat, offset, 255, CV_THRESH_BINARY);
  </code></pre>