Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to merge Images and impose on each other

Suppose I'm uploading two or more than two pics in some Framelayout. Hereby I'm uploading three pics with a same person in three different position in all those three pictures. Then what image processing libraries in Android or java or Native's are available to do something as shown in the pic.

I would like to impose multiple pictures on each other.

Something like these:-

Picture with layering facility

One idea is to :

  1. Do some layering in all those pictures and find mismatching areas in the pics and merge them.

How one can merge multiple picture with other? By checking the di-similarity and merge with each other?

Are there any Third party Api's or some Photoshop service which can help me in doing these kinda image processing?

like image 382
Vikalp Patel Avatar asked Aug 18 '13 11:08

Vikalp Patel


1 Answers

In this case you are not just trying to combine the images. You really want to combine a scene containing the same object in different positions.

Therefore, it is not just a simple combination or an alpha compositve where the color of a given pixel in the output image is the sum of the value of this pixel in each image, divided by the number of images.

In this case, you might do:

  1. Determine the scene background analysing the pixels that do not change considering multiple images.
  2. Begin with the output image being just the background.
  3. For each image, remove the background to get the desired object and combine it with the output image.

There is a Marvin plug-in to perform this task, called MergePhoto. The program below use that plug-in to combine a set of parkour photos.

import marvin.image.MarvinImage;
import marvin.io.MarvinImageIO;
import marvin.plugin.MarvinImagePlugin;
import marvin.util.MarvinPluginLoader;

public class MergePhotosApp {

public MergePhotosApp(){

    // 1. load images 01.jpg, 02.jpg, ..., 05.jpg into a List
    List<MarvinImage> images = new ArrayList<MarvinImage>();
    for(int i=1; i<=5; i++){
        images.add(MarvinImageIO.loadImage("./res/0"+i+".jpg"));
    }

    // 2. Load plug-in and process the image
    MarvinImagePlugin merge = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.combine.mergePhotos");
    merge.setAttribute("threshold", 38);

    // 3. Process the image list and save the output
    MarvinImage output = images.get(0).clone();
    merge.process(images, output);
    MarvinImageIO.saveImage(output, "./res/merge_output.jpg");
}

public static void main(String[] args) {
    new MergePhotosApp();
}
}

The input images and the output image are shown below.

enter image description here

like image 152
Gabriel Ambrósio Archanjo Avatar answered Sep 20 '22 06:09

Gabriel Ambrósio Archanjo