OpenCV is a Computer Vision library that helps you manipulate images and videos in a way of doing different processing techniques over them.

In this post, we are going to show you, how can you blend images, in order to create one image from a few others. Before reading this post about blend images, here we have another one about barcode detection using OpenCV.

## The Image Blending Problem

In this post, we are going to use two pictures, and we are going to blend them into one picture. We are going to use Gaussian and Laplacian pyramids in order to resize the images.

An image pyramid is a collection of images, which arise from one source i.e. one original image. In order to create a pyramid, we need to downsample the source image until some desired stopping point is reached.

There are two types of image pyramids: Gaussian pyramid (Used to downsample images) and Laplacian pyramid (Used to reconstruct an upsampled image from an image lower in the pyramid (with less resolution)).

In our example, we are going to use both of these types of pyramids. With the Gaussian, we are going to downsample our images so later we can reconstruct them in order to lose some of their resolutions and their colors look more similar to others.

Image 1: Apple That We Will Use In This Image Blending Problem

Image 2: Orange That We Are Going To Use To Blend Images

Copy to Clipboard

Now we reconstruct the image, in order to get the result.

Image 3: The Result Of The Image Blending

We can also blend images by just directly connecting the two images, with the code below.

Copy to Clipboard

Image 4: Result Of Direct Blending

As we can see the result of the direct blending is not nearly precise as the result we get by applying Gaussian and Laplacian pyramid.

If you want to see a video tutorial of this problem, we suggest you check this YouTube video.

## Conclusion

This post is an example of how can you manipulate images by creating one image you like from a few others, by using programming code instead of some graphics editors like Photoshop or Gimp.

OpenCV is a very popular and powerful Computer Vision library, and we have other posts where we showcase examples of image processing using this library.

We hope that we spark a little interest in you so you will be learning more about Computer Vision since this field is one of the fastest-growing fields in the Artificial Intelligence discipline.

### Don’t forget to read other related articles:

Like with every post we do, we encourage you to continue learning, trying and creating.