Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect shape in a image with php?

Tags:

php

image

gd

I have to detect 'star' like shape in a image with php.Also the star is not fixed and may be at other position next time.I cannot use any external software or library.I have tried all methods like edge detection and grayscaling but all in vain.this is the image:enter image description here

the main problem is I cannot clear the background. if image background is cleared than i can read all pixels color row wise as well as column wise and detect.please help me.this is the image after brightness_filter and edge detection. enter image description here

like image 426
viki Avatar asked Oct 03 '22 16:10

viki


2 Answers

For this particular image would suggest to perform a low amount of lowpass filtering (Gaussian blur) to attenuate those lines. That should work because thin lines have high frequencies at their transistions. And then you can try increasing the contrast and the brightness.

I just did a quick test and the result is something like that enter image description here

Then just calculate the cross-correlation of your resulting image with images of different stars.

like image 146
lmNt Avatar answered Oct 13 '22 00:10

lmNt


If the star itself isn't scaled or rotated, then you should be able to detect it from the 2D convolution of a clean star image with your source image.

If you are trying to find stars with different scales and rotations, it would probably be better to clean up the image with an erosion filter, then use edge detection and a Hough transform to find the edges.

like image 27
r3mainer Avatar answered Oct 12 '22 23:10

r3mainer