title: How to handle ImgData in C#?
body: <p>I'm trying to implement an retinex filter following the one posted <a href="http://blog.csdn.net/onezeros/article/details/6342661" rel="nofollow">here</a>. At the beginning he defines:</p>
  
  <pre><code>#define pc(image, x, y, c) image-&gt;imageData[(image-&gt;widthStep * y) + (image-&gt;nChannels * x) + c]
  </code></pre>
  
  <p>and when doing the gaussian convolution he is using it as:</p>
  
  <pre><code>v1 += kernel[k] * (unsigned char)pc(temp, i, source, 0);
  </code></pre>
  
  <p>and later:</p>
  
  <pre><code>pc(img, i, j, 0) = (char)int2smallint(v1); 
  </code></pre>
  
  <p>I'm not able to translate this to C#, neither do I understand what he's doing exactly. There are no unsigned chars in C# and also the way he access the image data is completely different. So, what is the best way to implement this in C#?</p>