c++opencvimage-processinghandwriting-recognition

Find the width of an ink stroke in an image using OpenCV & C++


I have the following sample of handwriting taken with three different writing instruments:

enter image description here

Looking at the writing, I can tell that there is a distinct difference between the first two and the last one. My goal is to determine an approximation of the stroke thickness for each letter, allowing me to group them based on being thin or thick.

So far, I have tried looking into stroke width transform, but I have struggled to translate it to my example.

I am able to preprocess the image such that I am just left with just the contours of the test in question. For example, here is thick from the last line:

enter image description here


Solution

  • I suggest detecting contours with cv::findContours as you are doing and then compare bounding rectangle area and contour area. The thicker writing the greater coefficent (contourArea/boundingRectArea) will be.