How can I determine color of contour? [closed]

asked 2016-06-19 20:59:51 -0600

Dinh Thap gravatar image

How can I determine color of contour?Thanks.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-08 02:30:31.264308

Comments

1

hi, what you're asking is a bit unclear. can you try to explain more ?

berak gravatar imageberak ( 2016-06-20 00:57:05 -0600 )edit

I want to determine color of character So I use findContour to find all contour of character in my image and Finally I want to determine color of the contour. Can you suggest me some way to do that? Thanks.

Dinh Thap gravatar imageDinh Thap ( 2016-06-20 04:49:45 -0600 )edit

hmm, a contour is just a vector<Point> , so you could query the underlying pixel for each Point like: img.at<Vec3b>(contour[i]) .

unfortunately, those values won't be the same for each Point, a contour (being the 'outside' of something) usually does not have a 'single' colour.

berak gravatar imageberak ( 2016-06-20 04:53:53 -0600 )edit

are you looking for the colour of the inside of a contour ?

you could try to find it's center (e.g. from moments()) , and query the pixel value there.

berak gravatar imageberak ( 2016-06-20 04:56:18 -0600 )edit

That's right. Unfortunately, a contour usually does not have a single contour. Can you suggest me some way to do that?

Dinh Thap gravatar imageDinh Thap ( 2016-06-20 04:58:05 -0600 )edit

YES. inside a contour. at stroke width not at overlap contour.

Dinh Thap gravatar imageDinh Thap ( 2016-06-20 05:00:39 -0600 )edit

Nope. Center returns color of background not color of word

Dinh Thap gravatar imageDinh Thap ( 2016-06-20 05:01:34 -0600 )edit

maybe this will be helpful

sturkmen gravatar imagesturkmen ( 2016-06-23 14:01:46 -0600 )edit