Ask Your Question

Revision history [back]

Hi @Chorongiee!

This image work pretty good in my code & it is correctly detecting your required border. Check your Canny image output it seems like it is containing some white pixels in the outer border. other than that it looks good.

If you want some other better approach try this.

  1. Load BGR image & convert it into HSV Image.
  2. Now filter the black regions by filtering the HSV Range V- 100 to 255. The result will look like this.

image description

  1. Apply Gaussian smooth & threshold binary so smooth the edges if you want.
  2. Find contours with RETR_TYPE.CV_RETR_EXTERNAL to find only the outer most contours.
  3. Result is your required output image.