Ask Your Question

Revision history [back]

How to crop an image which has missing borders using opencv java

I am trying to build a document scanner using openCV. I am trying to auto crop an uploaded image. I have few use cases where there is a gap in the border when the document is out of frame(captured image).

Ex image

C:\fakepath\unnamed.jpg

Below is the canny edge detection of the given image.

C:\fakepath\canned.jpg

The borders are missing here and findContours does not return me proper results due to this. How can I handle such images.

Both automatic canny edge detection as well as dilate does not work in such cases because it can join only small edges.

Also few documents might have only 2 sides or 3 sides captured using camera and how can we crop the other areas which is not required.

Example Image:

C:\fakepath\unamed2.jpg

Is there any specific technique for handling such documents? Please suggest few ideas.

Source Code: gist.github.com/sureshbabuinfo/f398a758dbbec64eee2d7c8221b0c970

How to crop an image which has missing borders using opencv java

I am trying to build a document scanner using openCV. I am trying to auto crop an uploaded image. I have few use cases where there is a gap in the border when the document is out of frame(captured image).

Ex image

C:\fakepath\unnamed.jpgC:\fakepath\unnamed.jpg

Below is the canny edge detection of the given image.

C:\fakepath\canned.jpgC:\fakepath\canned.jpg

The borders are missing here and findContours does not return me proper results due to this. How can I handle such images.

Both automatic canny edge detection as well as dilate does not work in such cases because it can join only small edges.

Also few documents might have only 2 sides or 3 sides captured using camera and how can we crop the other areas which is not required.

Example Image:

C:\fakepath\unamed2.jpgC:\fakepath\unamed2.jpg

Is there any specific technique for handling such documents? Please suggest few ideas.

Source Code: gist.github.com/sureshbabuinfo/f398a758dbbec64eee2d7c8221b0c970

How to crop an image which has missing borders using opencv java

I am trying to build a document scanner using openCV. I am trying to auto crop an uploaded image. I have few use cases where there is a gap in the border when the document is out of frame(captured image).

Ex image

C:\fakepath\unnamed.jpg

Below is the canny edge detection of the given image.

C:\fakepath\canned.jpg

The borders are missing here and findContours does not return me proper results due to this. How can I handle such images.

Both automatic canny edge detection as well as dilate does not work in such cases because it can join only small edges.

Also few documents might have only 2 sides or 3 sides captured using camera and how can we crop the other areas which is not required.

Example Image:

C:\fakepath\unamed2.jpg

Is there any specific technique for handling such documents? Please suggest few ideas.

Source Code: gist.github.com/sureshbabuinfo/f398a758dbbec64eee2d7c8221b0c970