How to get the position of a certain color range from an image?

xmas tree

I have an image of an Xmas tree with different circles on its branches. You can see that the circles have different colors: green, red, yellow, etc.

I need to find the position of the circles using PHP.

Is this possible with the PHP GD library?

If possible, please suggest me how I can calculate the position of x and y circles.

+4
source share
1 answer

This is not possible in the GD library, but with imagemagick.

Color changes and their location in images can be found through Edge Detection .

There is a good cover for php on this blog .

There is no general script I could give you, since you find the correct algorithm 4, the original image is an iterative process.

first you try to filter out the dark green colors of the tree from the original image, then you can run edge detection to get the edges of the circles in the grayscale image.

Once you are there, you need some kind of circle definition. google found this interesting thread

Hope this helps you in the right direction.

+3
source

Source: https://habr.com/ru/post/1432937/


All Articles