Hi! Your first guess is I think the best way to handle this problem. The fact that a line is broken into multiple lines is not a problem : just take the orientation of each line (in degree for example), put them into a vector and try to count vertical lines ((angle>80&&angle<100) || (angle>260&&angle<280)) and horizontal lines (angle<10 || angle>350 || (angle>170&&angle<190)). Using the ratio of those values to the total number of lines, you will probably be able to find the right class... But of course, if the image is slightly rotated, this method will not work...