void LSI_roll(int *Raw, float *SpeckleContrast, float *SpeckleFlowIndex, int *rollRow, int *rollColumn, int *rollRowSquared, int *rollColumnSquared, int width, int height, int wR, float t) { int w = wR*2 + 1; int els = w*w; float iDoF = (float)1.0/(els*(els-1)); int i, j; // Step 1) Calculate first accumulated sum to start // Perform analysis on first accumulated row for (i=0; i=w) { rollColumn[i] = rollColumn[i-1] - rollRow[i-w] + rollRow[i]; rollColumnSquared[i] = rollColumnSquared[i-1] - rollRowSquared[i-w] + rollRowSquared[i]; SpeckleContrast[wR*width+i-wR] = (els * sqrt((float)iDoF*(els*rollColumnSquared[i]-(rollColumn[i]*rollColumn[i]))))/rollColumn[i]; SpeckleFlowIndex[wR*width+i-wR] = (float)1/(2*SpeckleContrast[wR*width+i-wR]*SpeckleContrast[wR*width+i-wR]*t); } else { rollColumn[w-1] += rollRow[i]; rollColumnSquared[w-1] += rollRowSquared[i]; if(i==(w-1)) { SpeckleContrast[wR*width+i-wR] = (els * sqrt((float)iDoF*(els*rollColumnSquared[w-1]-(rollColumn[w-1]*rollColumn[w-1]))))/rollColumn[w-1]; SpeckleFlowIndex[wR*width+i-wR] = (float)1/(2*SpeckleContrast[wR*width+i-wR]*SpeckleContrast[wR*width+i-wR]*t); } } } // Step 2) Perform optimized roll algorithm // Cumulate rows and columns simultameously // Calculate SC and SFI immediately for (j=w; j=w) { rollColumn[i] = rollColumn[i-1] - rollRow[i-w] + rollRow[i]; rollColumnSquared[i] = rollColumnSquared[i-1] - rollRowSquared[i-w] + rollRowSquared[i]; SpeckleContrast[(j-wR)*width+i-wR] = (els * sqrt((float)iDoF*(els*rollColumnSquared[i]-(rollColumn[i]*rollColumn[i]))))/rollColumn[i]; SpeckleFlowIndex[(j-wR)*width+i-wR] = (float)1/(2*SpeckleContrast[(j-wR)*width+i-wR]*SpeckleContrast[(j-wR)*width+i-wR]*t); } else { rollColumn[w-1] += rollRow[i]; rollColumnSquared[w-1] += rollRowSquared[i]; if(i==(w-1)) { SpeckleContrast[(j-wR)*width+i-wR] = (els * sqrt((float)iDoF*(els*rollColumnSquared[w-1]-(rollColumn[w-1]*rollColumn[w-1]))))/rollColumn[w-1]; SpeckleFlowIndex[(j-wR)*width+i-wR] = (float)1/(2*SpeckleContrast[(j-wR)*width+i-wR]*SpeckleContrast[(j-wR)*width+i-wR]*t); } } } } }