Ask Your Question
0

How to draw filled contours on the top of another filled contour with different filled color/intensity?

asked 2017-10-09 08:45:05 -0600

kyuu gravatar image

Hi, I use OpenCV 3.0 and I have a shape A to detect. (See the attachment picture).

My aim is to detect the shape A and draw the contour with filled contour using the same intensity for each contour (1 dimension matrix only). The idea is to give the inner circles higher intensity over the outer as shown by C on the attachment.

I can detected the circles using thresholding and contour detection. However, when I loop on the detected contour to draw the contours, the result is one contour with the same intensity only as shown by B on the attachment picture.

it seems like the looping is not adding the intensity on each iteration.

can someone help me out ?? Thanks.

image description

edit retag flag offensive close merge delete

Comments

One simple solution is to sort the contours by Area and Set Respective Color Value to the Individual contours!

Balaji R gravatar imageBalaji R ( 2017-10-09 10:10:27 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-10-11 07:36:32 -0600

You will need several things

  • You will need to detect contours with a hierarchy, else only the outer contour is returned.
  • Then you will need to have a look at how hierarchy works.
  • Then you can couple the pixel intensities to the correct contour.
  • Finally you can draw them starting with the largest one.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-10-09 08:45:05 -0600

Seen: 663 times

Last updated: Oct 11 '17