Search code examples
c++opencvsegment

Segment A Picture In Opencv


i using c++ with opencv, i can't do segment pictures like this:

(sorry for my english)

PICTURE 1 PICTURE 2

i want segment the sheet, removing the background located at the edges. i trying use "watershed" to locate the position of the sheet, but had a problem with the image format, i don't know if there another algorithm that work me.

the idea is crop the white sheet, removing the background, unknow the size and position of the sheet. but always in the center of the image looks the sheet, someone can help me?

Thanks!!


Solution

  • You can do some thing like,

    1. Threshold the image, here assume the image with white sheet.

    2. Now find contour and select largest contour.

    3. Now get the bounding box for the largest contour and crop the sheet.