Ask Your Question
0

access pixel values inside the detected object / c++

asked 2013-12-04 07:49:35 -0600

ati gravatar image

If I could detect a circle by using canny edge detector, How can I have access to all values which are inside the circle?

void Canny(InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false ) output of this function will give me the edges values which is detected by the edge detector, but what I want is all value inside the circle.

thanks in advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-12-04 09:30:02 -0600

Haris gravatar image

You can solve the issue by the following,

  • Using hough circle detect the circle.
  • Draw the detected circle in new Mat(single channel) using OpenCV circle, here you need to set thickness = -1 and Scalar=255, which fill the circle with your scalar value.
  • Now scan your source image as well as the newly created Mat, and access the source image pixel only when the newly created Mat has the pixel value 255.

And you can see OpenCV Doc about how to scan image here

edit flag offensive delete link more

Comments

thanks for the answer but actually, circle was just an example. what should I do if I have an object without having any specific shape?

ati gravatar imageati ( 2013-12-04 10:06:54 -0600 )edit
2

Then try with contour processing like findcontour(), dtawcontour() etc...where you can fill the contour by setting appropriate parameter(thickness=CV_FILLED). See opencv contour example for more details http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html

Haris gravatar imageHaris ( 2013-12-04 10:55:14 -0600 )edit

Question Tools

Stats

Asked: 2013-12-04 07:49:35 -0600

Seen: 1,265 times

Last updated: Dec 04 '13