What is "not powerful enough" in terms of MIPS, MHz, anything?
What accuracy do you need?
Correct and slow way is to calculate correlation function of your signal and function you are looking for (step function in simple case). And then find the position of maximum of correlation function. This also could be done in different ways depending on required accuracy: just take position of maximum value, or approximate around maximum with some polynom(parabolic) and calculate maximum position analytically.
Let's say edge is smooth in area of about 30 pixels, then such calculation would require just: 256 * 30 = 8k multiplications with accumulation, and 256 compartions in order to find maximum.
Fast way is to calculate derivative, filter it a little bit, and then locate maximum of this derivative.
something like:
Code:
#define K 10
int Calc(int * d){
int y0 = 0, y1 = 0, max = 0, pos = 0;
for (int i = 1; i < 256; i++){
y1 = y0 + (d[i] - d[i-1] - y0) / K;
y0 = y1;
if (y1 > max) {max = y1;pos = i;}
}
return pos;
}
Or combining both could improve accuracy with a little overhead: at first locate maximum by finding point with maximum derivative, then calculate correlation function in range of few pixels around in order to get more precise result.
Subtract it