title: cvGet2D alternative
body: <p>I am processing video frames in real time. I loop through each pixel one at a time, do some math, and then set the pixel to a specific color (if necessary). </p>
  
  <p>In a nutshell, my algorithm looks like this:</p>
  
  <pre><code>     //videoFrame is IplImage, 8 bit, 4 channel
       for(int i=0;i&lt;videoFrame.width;i++){
          for(int j=0;j&lt;videoFrame.height;j++){
  
              CvScalar pixel = cvGet2D(&amp;videoFrame, i, j);
  
              double red = pixel.val[0];
              double green = pixel.val[1];
              double blue = pixel.val[2];
  
              //do some math
  
  
              if (someCondition) {
                  cvSet2D(&amp;videoFrame, i, j, white);
              }
          }       
      }
  </code></pre>
  
  <p>but i find that calls <code>cvGet2D(&amp;videoFrame, i, j);</code> and <code>cvSet2D(&amp;videoFrame, i, j, white);</code> are really expensive(slow). Is there an alternative faster way I can access red/green/blue value of each pixel?</p>
  
  <p>Thanks!</p>