# Blob Roundness Help

What is the process/math blob roundness does to calculate the value it outputs?

Right here:

``````// http://www.cse.usf.edu/~r1k/MachineVisionBook/MachineVision.files/MachineVision_Chapter2.pdf
// https://www.strchr.com/standard_deviation_in_one_pass
//
// a = sigma(x*x) + (mx*sigma(x)) + (mx*sigma(x)) + (sigma()*mx*mx)
// b = sigma(x*y) + (mx*sigma(y)) + (my*sigma(x)) + (sigma()*mx*my)
// c = sigma(y*y) + (my*sigma(y)) + (my*sigma(y)) + (sigma()*my*my)
//
// blob_a = sigma(x*x)
// blob_b = sigma(x*y)
// blob_c = sigma(y*y)
// blob_cx = sigma(x)
// blob_cy = sigma(y)
// blob_pixels = sigma()

float b_mx = blob_cx / ((float) blob_pixels);
float b_my = blob_cy / ((float) blob_pixels);
int mx = fast_roundf(b_mx); // x centroid
int my = fast_roundf(b_my); // y centroid
int small_blob_a = blob_a - ((mx * blob_cx) + (mx * blob_cx)) + (blob_pixels * mx * mx);
int small_blob_b = blob_b - ((mx * blob_cy) + (my * blob_cx)) + (blob_pixels * mx * my);
int small_blob_c = blob_c - ((my * blob_cy) + (my * blob_cy)) + (blob_pixels * my * my);

find_blobs_list_lnk_data_t lnk_blob;
memcpy(lnk_blob.corners, corners, FIND_BLOBS_CORNERS_RESOLUTION * sizeof(point_t));
memcpy(&lnk_blob.rect, &rect, sizeof(rectangle_t));
lnk_blob.pixels = blob_pixels;
lnk_blob.perimeter = blob_perimeter;
lnk_blob.code = 1 << code;
lnk_blob.count = 1;
lnk_blob.centroid_x = b_mx;
lnk_blob.centroid_y = b_my;
lnk_blob.rotation = (small_blob_a != small_blob_c) ? (fast_atan2f(2 * small_blob_b, small_blob_a - small_blob_c) / 2.0f) : 0.0f;
lnk_blob.roundness = calc_roundness(small_blob_a, small_blob_b, small_blob_c);
lnk_blob.x_hist_bins_count = 0;
lnk_blob.x_hist_bins = NULL;
lnk_blob.y_hist_bins_count = 0;
lnk_blob.y_hist_bins = NULL;
// These store the current average accumulation.
lnk_blob.centroid_x_acc = lnk_blob.centroid_x * lnk_blob.pixels;
lnk_blob.centroid_y_acc = lnk_blob.centroid_y * lnk_blob.pixels;
lnk_blob.rotation_acc_x = cosf(lnk_blob.rotation) * lnk_blob.pixels;
lnk_blob.rotation_acc_y = sinf(lnk_blob.rotation) * lnk_blob.pixels;
lnk_blob.roundness_acc = lnk_blob.roundness * lnk_blob.pixels;
``````

https://www.strchr.com/standard_deviation_in_one_pass