1 | initial version |
First, you split the image vertically in the middle and process both sides individually. You then use cv::Houghlines (http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html) to find the horizontal lines that separate the segments. cv::Houghlines will give you a lot of lines, but you can easily filter them by angle and length.
2 | No.2 Revision |
a) First, you split the image vertically in the middle and process both sides individually. You then use cv::Houghlines (http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html) to find the horizontal lines that separate the segments. cv::Houghlines will give you a lot of lines, but you can easily filter them by angle and length.
b) (again, split vertically first). Binarize the image, e.g. with cv::adaptiveThreshold. Divide the image in horizontal strips with a height of 2-3 pixels. Then count the number of columns in this strip in which there is at least one black pixel. The strips that contain the horizontal lines should have a significant higher number of columns with a black pixel than the other strips. However, finding good parameters for the thresholding could be difficult.
3 | No.3 Revision |
a) First, you split the image vertically in the middle and process both sides individually. You then use cv::Houghlines (http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html) to find the horizontal lines that separate the segments. cv::Houghlines will give you a lot of lines, but you can easily filter them by angle and length.
b) (again, split vertically first). Binarize the image, e.g. with cv::adaptiveThreshold. Divide the image in horizontal strips with a height of 2-3 pixels. Then count the number of columns in this strip in which there is at least one black pixel. The strips that contain the horizontal lines should have a significant higher number of columns with a black pixel than the other strips. However, finding good parameters for the thresholding could be difficult.
c) manually create a template image for the horizontal line and use cv::MatchTemplate to find all instances.