+void DebandOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+{
+ float v[4]; /*The pixel's RGB value*/
+ float inputTreshold[4]; /* How large a banding step our codec produces may be. */
+ float inputRadius[4]; /* How wide our maximal searching and blur range will be.*/
+
+ this->m_inputProgram->read(v, x, y, sampler);
+ this->m_inputTresholdProgram->read(inputTreshold, x, y, sampler);
+ this->m_inputRadiusProgram->read(inputRadius, x, y, sampler);
+
+ int width = this->m_inputProgram->getWidth();
+ int height = this->m_inputProgram->getHeight();
+
+ float treshold = inputTreshold[0];
+ float radius = inputRadius[0];
+ int channels;
+ treshold /= 100.0f;
+
+ int i, j;
+ int changex = 0, changey = 0; /* Store the number of pixels in treshold we detected within our search radius */
+ float valuex[4], valuey[4]; /* Store the culminated values of all detected pixels in range. Later we will divide this by the detected pixel to geht the average value */
+ float v2[4]; /* The value of the pixel we currently compare with the base pixel */
+ int position2; /* The position of the pixel we currently compare with the base pixel */
+
+ /* If we want to use the node for separate channels with a separate RGB node for example,
+ we only need to apply the effect to the first input channel*/
+ if (this->m_singlechannel) {
+ channels = 1; }
+
+ else {
+ channels = 3; }
+
+ /* Look for banding steps in x and y direction. There must be at least three pixels in the treshold range
+ to assume our actual pixel is on a banding step. If there were only two, it might also be a pixel in a
+ slight gradient. If we encounter a step that is larger than treshold, we stop here because we assume that
+ we have reached the end of the banding area. */
+ for (i=0; i < channels; i++) {
+
+ changex = 0;
+ changey = 0;
+ valuex[i] = 0;
+ valuey[i] = 0;
+
+ for (j = 1; j<= radius; j++){
+
+ position2 = x + j;
+
+ if (position2 >= width) {
+ break;}
+
+
+ this->m_inputProgram->read(v2, position2, y, sampler);