Skip to content

Instantly share code, notes, and snippets.

@cmastudios
Created January 24, 2015 01:53
Show Gist options
  • Save cmastudios/744a931f83c6ff0f7a6a to your computer and use it in GitHub Desktop.
Save cmastudios/744a931f83c6ff0f7a6a to your computer and use it in GitHub Desktop.
stddev
double contour_average_distance(Mat image, Contour contour)
{
double average = 0;
for (Point pt : contour) {
average += Calculate_Real_Distance(image, pt);
}
return average / contour.size();
}
double contour_stddev(Mat image, Contour contour)
{
double ave_dist = contour_average_distance(image, contour);
double variance = 0;
for (Point point : contour) {
double dist = Calculate_Real_Distance(image, point);
double diff_mean = ave_dist - dist;
variance += pow(diff_mean, 2);
}
variance = variance / contour.size();
return sqrt(variance);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment