I'm trying to write an image fusion program in OpenGL/GLSL. At one point I need to calculate a cumulated histogram for a 7x7 pixel area. In fragment shader I'm trying to use a function:
float graythresh(float aArea[49])
{
float hist[256];
for(int i = 0; i < 49; i++)
hist[(int)(aArea*255)]+= 1.0;
for(int i = 0; i < 256; i++)
hist /= 49.0;
for(int i = 255; i >= 0; i--)
for(int j = 255; j >= 0; j--)
if(j > i)
hist += hist[j];
return 0.0;
}
The last loop causes application crash and error "driver stopped responding". I tried using older drivers, and testing the application on different computer, nothing changed.
for(int i = 255; i >= 0; i--)
for(int j = i-1; j >= 0; j--)
hist += hist[j];
Gave same error. Is it even possible to this?
Thanks in Advance, any help will be appreciated.
(I'm using GeForce GT 420M, windows 7)