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

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 close merge delete

Sort by ยป oldest newest most voted

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.

more

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

( 2016-05-14 22:21:50 -0500 )edit

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

( 2016-05-16 12:06:21 -0500 )edit

Precisely, yes.

( 2016-05-16 18:17:35 -0500 )edit

Official site

GitHub

Wiki

Documentation