Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:09:00+00:00 2026-06-04T16:09:00+00:00

The OpenCV cvFindContour() method gets connected components following the 8-connected neighbors rule. Is there

  • 0

The OpenCV cvFindContour() method gets connected components following the 8-connected neighbors rule. Is there any way to change it into a 4-connected neighbor rule – the corner cells will not be taken into account when checking for connectedness.

Apparently Mathematica does this with a simple CornerNeighbors->False shown here on SO.
Any way of doing this in OpenCV? Even if we were to actually change the function definition in the cv*.h file (which is rather hairy) … any pointers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:09:01+00:00Added an answer on June 4, 2026 at 4:09 pm

    I am afraid this is impossible, you could consider suggesting a code-change to opencv, adding a flag that would allow this. Currently in this file:

    http://code.opencv.org/projects/opencv/repository/entry/trunk/opencv/modules/imgproc/src/contours.cpp

    there is an array called icvCodeDeltas which determines all the neighbours. You could check where it is used and add a

    static const CvPoint icvCodeDeltas4[4] =  { {1, 0}, {0, -1}, {-1, 0}, {0, 1} };
    

    which is used when for example the CV_NEIGHBOURS_CROSS is specified. Then ask the opencv-community to add it, the way open source works. Maybe a quick, dirty, you-should-be-ashamed fix would be something like this:

    virtual CvPoint icvCodeDeltas[8];
    icvCodeDeltas =  { {1, 0}, {0, -1}, {-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 0}, {0, 1} };
    

    But I did not test that, and I have no idea if this will avoid the ‘static’ and ‘const’ so be careful 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in OpenCV 2 and later there is method Mat::resize that let's you add any
Are there any opencv function like cvHoughCircles() that can use for square detection programming
I am using cvFindContour function of opencv and in it there is a parameter
Are there any OpenCV cross compilers available for MICROCONTROLLERs? Thanks
Using OpenCV, saving a CvMat structure into a YAML file on the disk is
Is there an OpenCV function to draw an image over another image? I have
In openCv when we change the type of the matrix from CV_8U to CV_64F
In OpenCV when displaying an image with: cvSetWindowProperty(displayCVWindow, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); There is a small
I'm using OpenCV to match a bunch of viewpoints into a panorama. The result
In OpenCV, there is a CvSVM class which takes in a matrix of samples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.