Q: how to find bad points in a linear interpolation? I have a set of points and I know that:


*

*All of them are from 0-255 

*They are in increasing format (so Point[0] <= Point[1]) 

*They are repressing a line (with some noise).


But there are some points that behave badly. I need to detect that points. What is the fastest way to do this?
In general I can get the first one and last one and find the line formula and then calculate error for each point and if the error is too high, I mark that point as bad point. 
Is there any better way (faster and more accurate)?
Is there any library that can help (I am using OpenCV and Boost).

A: Instead of taking first and last points, you should calculate linear regression and measure the distance of points from that trend line instead. It could be that your first/last point behaves badly.

A: run a loop through them, if p[i] < p[i-1], then it's behaving badly.
i dont know why you mention lerp, it sounds unrelated. lerp functions can't return wrong results.
