0

I want to identify an object inside the image. For example, according to the below tshirt image I want to identify the smiley face with the x,y coordinates of its starting position and the width & height properties of that smiley image. How can I do something like that using php? The background color of the tshirt will always be only one color.
enter image description here

user3894236
  • 114
  • 2
  • 14
  • That would be quite complicated, you might want to try to detect anything that is not a tshirt and then find a rectangle that surrounds an object – insanebits Jul 11 '15 at 17:08
  • It would be easier to make the smiley a png with a transparent background and then use a image library to merge them or draw them over eachother on a html 5 canvas – kurt Jul 11 '15 at 17:09
  • @insanebits Any suggestions on how to do that? – user3894236 Jul 11 '15 at 17:09
  • @kurt How can I make the smiley png to a tranceparent background? I mean how to identify that? – user3894236 Jul 11 '15 at 17:12
  • @user3894236 I'm not that experienced in image processing but I think easiest route would be to change range of tshirt color(it will be couple of shades of the same color) and then find the pixels closest to the each side, but it wouldn't reliable, since images have artifacts. – insanebits Jul 11 '15 at 17:16
  • I would use a open source image editor like gimp, save 10 + color t-shirts and then draw on them. Php isnt the best for working with images further than converting and resizing them. Otherwise depinging on what you need it for try javascript and a canvas element, then you could use a single colored shirt and adjust the rbg values to change its color and draw the smiley over it. A canvas renders your drawing as an image – kurt Jul 11 '15 at 17:17
  • @kurt Actually I don't want to draw the image into canvas. Think the above image is already created. And what I want is to read the position(x,y coordinates) and size(width,height) of the clipart. – user3894236 Jul 11 '15 at 17:21
  • then you going to have to loop through the entire image pixel by pixel and map it based on the color of each pixel. i.e blue shade, orange shade – kurt Jul 11 '15 at 17:24
  • @kurt By iterating through pixels how can I identify the x,y coordinates?If possible can you give me a code example? – user3894236 Jul 11 '15 at 17:27
  • have a look through the php documentation, theres plenty of samples http://php.net/manual/en/function.imagesetpixel.php – kurt Jul 11 '15 at 17:29

0 Answers0