I'm trying to denoise the image then extract the skeleton of an image containing a handwritten line. I want the line to be continuous and solid but the method I use fails to do that and relatively slow. Here's the original image: Original Image
Morphed On the morphed image, you can see a small island at the lower right.
The thinned image from above shows the line is broken near the end.
Any other method to achieve desired result?
My code looks like this:
int morph_elem = 2;
int morph_size = 10;
int morph_operator = 0;
Mat origImage = imread(origImgPath, CV_LOAD_IMAGE_COLOR);
medianBlur(origImage, origImage, 3);
cvtColor(origImage, origImage, COLOR_RGB2GRAY);
threshold(origImage, origImage, 0, 255, THRESH_OTSU);
Mat element = getStructuringElement(morph_elem, Size(2 * morph_size + 1, 2 * morph_size + 1), cv::Point(morph_size, morph_size));
morphologyEx(origImage, origImage, MORPH_OPEN, element);
thin(origImage, true, true, true);