收录日期:2019/05/24 23:39:08 时间:2010-03-05 19:03:51 标签:image-processing,image-manipulation,social-networking

I want to make an app that gets your friends profile pics from say your facebook,myspace or twitter account and makes an image out all of them. I already know how to use these social networks' APIs to get the image url, the question is, how do I "stitch" them together.

If you know how to do this using a specific class in Zend or PEAR that'll be great since that's what am using.

Thanks.

I would take a look at integrating Imagemagick into your solution

http://us3.php.net/imagick

I don't use it, but by looking at the examples, it start off like:

<?php
/* Create the big image. */
$im = new Imagick();
$im->newPseudoImage(500, 500, "white");

/* Create the small image. */
$faceImg = new Imagick('face.jpg');


?>

I don't see how to overlay $faceImg onto $im, but imagemagick has the functionality. If the PHP bindings are not good enough, you can always use the command-line version of ImageMagick.

A very basic approach is to take your target image (the image which you want your synthesized image to look like) and cut it out to smaller images into an image set we can call T.

  1. Find the "mean color" of each image in T.

  2. Take your set of friend images, let's call that set F, and find the "mean color" of each of those.

  3. Now match each image in T with an image in F so that the distance between colors is as small as possible. Here you'll have to consider whether you allow the same image in F to be used for more than one image in T.

A slightly less basic approach would be to (using same sets as above):

  1. Mean filter each image in T and F (as in blurring them)

  2. Match each image in T with an image in F by using least square error calculations.

Other more advanced approaches I can think of, but which are a lot more math heavy are:

  • Using Principal Component Analysis to pick out Principal Components from F and T and match those.
  • Using any kind of descriptor (SIFT, SURF, ...) to find an image in F in the target image. This would allow you to have an uneven grid, or really no grid at all where two images in F may very well end up having vastly different sizes in the resulting image.

As for framework I don't think it matters at all. What you need though is a good image library to make manipulating images easier.

I think there is a command in image magick to stitch images

convert 1.jpg 2.jpg -rotate 90 -append 270 final.jpg

I think this is what you are looking for