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

  • SEARCH
  • Home
  • 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 8232455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:50:26+00:00 2026-06-07T17:50:26+00:00

I have an image and I am using OpenCV to find the contours within

  • 0

I have an image and I am using OpenCV to find the contours within that image. For example:

contours, hierarchy = cv2.findContours(image, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

Each contour that get returned is sometimes very irregularly shaped. For example, the return of one of them is:

contour = [[[34  4]]
[[35  3]]
[[36  4]]
[[36 11]]
[[35 12]]
[[34 11]]
[[34  6]]
[[33  6]]
[[32  5]]
[[33  4]]]

I would like to set the interior of this contour to a specific color. I’ve tried using cv2.BoundingRect to get the bounding rectangle of this contour, and then using that to set the color, however, I would like a more precise way to do this using the actual contour.

Is there a straightforward way to do this through a function that OpenCV provides, or through NumPy?

  • 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-07T17:50:28+00:00Added an answer on June 7, 2026 at 5:50 pm

    Use cv2.drawContours() function with lineType = -1 flag (Docs)

    eg : cv2.drawContours(img,[cnt],0,color,-1) # for filling inside a specific contour

    or

    cv2.drawContours(img,contours,-1,color,-1) # to fill inside all the contours in a single step

    For more details, visit : Contours -1 : Getting Started

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

Sidebar

Related Questions

I have an .aspx file that outputs an image using the following methods: Server.MapPath(somefile.png)
I have a script that uploads an image using JavaScript, as seen here .
I have looked through all the OpenCV documentation that I could find and googled
I'm trying to display an image using OpenCV. I have the following very basic
I'm doing Augmented Reality research and am using OpenCV. I have the find checkerboard
I am using openCV's cvMatchTemplate method to find a smaller image in a bigger
I am using OpenCV for square detection in an image. The squares.c example is
I have a greyscale image which was created from a RGB image using farmula:
Is it possible to have transparent background image using CSS3? background: url(../img/bg_paperlines.jpg) repeat-x; Using
I have tried to upload image using FileTransfer.upload in phonegap api.But I am getting

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.