Medida de ancho de contorno a lo largo de toda su longitud

Estoy trabajando en un proyecto para medir el ancho del contorno. He detectado el contorno de la imagen (ver imagen 1). El siguiente paso es medir el ancho de la costura a lo largo de su longitud (como se muestra en la imagen 2). Por favor sugiérame alguna idea. ¡Realmente aprecio su ayuda!

¡Gracias!

imagen de contorno enmascarada

Medida de ancho requerida desde el contorno, las líneas verdes indican el ancho

Tengo una función que calcula los contornos y luego el siguiente paso es medir el ancho de los contornos seleccionados a lo largo de su longitud. A continuación se muestra el código de muestra.

...
// image is read, thresholded and canny edges are detected. That image is input to a function that computes contours from the image. 
///Below is the code in the contour function

cv::Mat src_contour= inputImage.clone(); // input image is cloned for contour detection
cv::Mat maskContour = cv::Mat::zeros(src_contour.size(), CV_8UC3);
std::vector<std::vector<cv::Point> > contours; // stores contours points. Each contour is stored in a vector and there are number of vectors for number of contours
cv::RNG rng(12345); // random number used for random colours of contours
cv::findContours( src_contour, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0) );

int nc=contours.size();// nc: total number of countours detected  

std::vector<int>areas(nc); // stores area of each contour in a vector
std::vector<double>arclens(nc); // stores arc length (perimeter) of each contour in a vector
std::vector<double>aspect_ratio(nc); // Apect ratio of the contour , width/height 
std::vector<cv::Rect> r(nc) ; // Vector of rectangles,

int min_area=15000 ; // Minimum area for contour selection 
int min_arclen=1000; // Minimum Arc length used for filtering contours 
double min_aspRatio= 2; // Minimum Aspect ratio used for filtering , deafutl 2.0
double max_aspRatio=4; // Maximum aspect rario used for filtering , default 4.0

for (int i=0; i< nc; i++) // Loop iterates through contours , calculates properties and draws selected contours 
{  
    areas[i]=cv::contourArea(contours[i],false); // Area of each contour is stored in a vector, false: any contour, true: closed contour
    arclens[i]=cv::arcLength(contours[i],false); // Arclength of each contour is stored in a vector 
    r[i]=cv::boundingRect(contours[i]); // Stores bounding rect for each contour in a vector r
    aspect_ratio[i]=float(r[i].width)/r[i].height; // Aspect ratio of each contour is stored in a vector 

    if ((areas[i] > min_area) && (arclens[i] > min_arclen) && (aspect_ratio[i] > min_aspRatio && aspect_ratio[i] < max_aspRatio)) 
    {   
        cv::drawContours(maskContour, contours, i, cv::Scalar(255,255,255), CV_FILLED); // creates mask from contours (filterd by criteria), fills them
    }
}

// maskContour image is the image of selected contours filled , I have access to all the points on the contour. From the selected contours
// need to compute width of contours 

.....
// Now contour width measurement is required 

Respuestas a la pregunta(1)

Su respuesta a la pregunta