Ask Your Question
0

how to determine the center of a star-like object?

asked 2016-05-14 09:15:47 -0600

choco gravatar image

hi guys i'm new to opencv! I wanted to know is there a way to find the center of a start-like object? as shown in this image star, it contain a star and other object. my question is:

  1. can i find the center based on the color pattern to create a result like this image with cross point? by then i am able to get the centre pixel location, right?
  2. in this image shuriken, since it doesn't have a clear color pattern, could i use the same approach in 1 to find the center?

i am willing to learn, so u may just provide the step/keyword then let me go figure out the coding part, but it may lead to more question from me :) if any tutorial of guideline link is provided it would be more helpful.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-05-14 15:14:35 -0600

Tetragramm gravatar image

The best way is to separate the image into just the star portion. That is, an image that is white where the star is, and black everywhere else. If you can do that, then finding the center is extremely simple. The function moments() will help you find the x and y location.

You only need the first and zeroth order moments. To get the x location, I believe it's m10/m00, and y is m01/m00. It could be the other way around, I always have to check myself.

So for your sample images, the second one is actually easier than the first. You convert to a gray image, threshold with OTSU and use the morphological OPEN to remove small specks. Then you use moments and it's done.

The first image is harder, you need to use some intelligence to get the star separate from the banner and stand. You might be able to do it with the Hough transform to find all the straight lines and find the ones that make a star. That would probably miss the corners where the banner is though. Using findCountours is another way you could separate the star from the base.

edit flag offensive delete link more

Comments

i guess this is the answer, i still doing it and need more time to digest, thanks for the guide

choco gravatar imagechoco ( 2016-05-14 22:21:50 -0600 )edit

hi, in this link, is this the moment i should prefer?

choco gravatar imagechoco ( 2016-05-16 12:06:21 -0600 )edit

Precisely, yes.

Tetragramm gravatar imageTetragramm ( 2016-05-16 18:17:35 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-05-14 09:12:13 -0600

Seen: 1,031 times

Last updated: May 14 '16