How about using below below method?
- Pushing the points of contours in white line edge.
- Using ransac to find two lines those are fit to upper and lower edge.
- Check the distance between the line point and the contour point.
- Detect the variance of those distance with 3 or 5 pixel widths.
- You could detect some threshold in both directional variance for erode and dilate cases.