I want to automatically select area of the page to crop later. I thought edge detection might be useful and used canny edge detection to find edges of the image. Now I have this image! but I've no clear idea to select area of the page as a rectangle. Can anyone suggest a method or implementation for this problem? What I really want to do is this selecting the area of the page as follows. Is there any other method to do this? I have also seen boundary detection in the book of introduction to digital image processing using matlab. But I'm not familiar with that. Can I use that for this purpose?
I assume that you have "Canny-ed" image. Now you can use
Imgproc.findCountours
, to find and store edges (you need List<MatOfPoint>
for that). Before using findContours
i would play with Imgproc.dilate
, which might help finding contours(it "fattens" lines so we are sure that findContours
wont miss your target). Then you need only to use Imgproc.boudningRect
to get your ROI. Then just crop image using this ROI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With