- At first i converted given image to grey scale
- Then i have applied threshold on greyscale image
- After then i looked for contours and iterate through them
- Approximated each contours Polygons
- By taking hight and width of contours, i cropped original images into parts
- Because of my limited knowledge on contour selection i cannot find best method to select only lines inside rectangle, so i used a technique in which i made two contours and subtracted on eachother
Two images with different contour selection method
Which produces this image
Similarly
By subtracting them we get following output
To align rectangle i have followed following steps