image filtering - histogram equalization with glsl shaders
<p>I need to implement some image filtering algorithms with glsl. As far as I understand, fragment shader code runs for every texel (pixel) in the image texture. So, implementing point (pixel) based filtering algorithms are easy (e.g. brightness/contrast change, sobel filter etc.). But, for tasks like histogram equalization or finding maximum pixel value in the image traversing all pixels are needed. However, in the shader code doing something like below is not the case.</p>

<pre><code>for (int y=0; y&lt;h; y++)
   for (int x=0; x&lt;w; x++)
</code></pre>

<p>Because, it causes traversing all image data per pixel.
My question is how  one can calculate the image histogram or find the maximum pixel value in the image? Is there any example code or tutorial for this?</p>