5

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?

Nam Vu
  • 5,563
  • 5
  • 52
  • 87
chAmi
  • 1,704
  • 3
  • 19
  • 27
  • 1
    duplicate: http://stackoverflow.com/questions/8667818/opencv-c-obj-c-detecting-a-sheet-of-paper-square-detection/ – ArtemStorozhuk Jun 26 '12 at 12:37
  • Thanks. I'll check it. Do you know about java implementation for those techniques? I prefer if i can avoid opencv or c++ for this. – chAmi Jun 26 '12 at 12:59
  • Yes, see [this tutorial](http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/android_binary_package.html#android-binary-package). But c++ will be much faster. – ArtemStorozhuk Jun 26 '12 at 13:15
  • I tried to do implement using purely java without opencv library for the android. But i also feel that it's too slow. Currently iv'e no experience with this opencv library for android but have with opencv. Do you think it is good to use rather than implementing java ? I mean is it not lead to unintended problems like crashing? I've to use high resolution images. – chAmi Jun 26 '12 at 13:25
  • OpenCV API for Android (c++) is the same as normal OpenCV (not for Android). And if you want to use it for high resolution images than you obviously have to code on c++. – ArtemStorozhuk Jun 26 '12 at 13:29
  • hey @chAmi I am also finding some auto cropping for image which detect object. Did you find any solution for this. Actually I am not familiar to OpenCV, is it possible to implement this using java only. – Dory May 31 '13 at 11:27
  • @chAmi: Have solve this problem. Can you please share the source code? – Manoj Oct 22 '13 at 04:20
  • @chAmi: Hi, I want to detect edges exactly like you have mentioned in image.can you guide? – Mehul Joisar Mar 06 '14 at 06:56
  • @chAmi. I am working with same thing you mentioned.Can you please share the source code if you have implemented? – Sanket Pandya Dec 24 '14 at 13:26

1 Answers1

1

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.

don_pablito
  • 262
  • 1
  • 8