In this example, we will demonstrate how we can perform image blending without actually preprocessing the two input images. Let's start:
seagull1.jpg
and seagull2.jpg
:>> A = imread('seagull1.jpg'), >> B = imread('seagull2.jpg'),
>> figure,imshowpair(A,B,'montage');
>> imshowpair(A,B,'blend');
'blend'
input and let MATLAB use the default choice ('falsecolor'
), which is to show the two images overlaid in different color bands:>> imshowpair(A,B);
'ColorChannel'
input. This input can assign the default ('green-magenta'
) choice, the 'red-cyan'
choice, or any arbitrary choice that can be generated using a [R G B] vector. Let's try the 'red-cyan'
choice:>> imshowpair(A,B,'ColorChannel','red-cyan'),
'RedCyanSeagulls.jpg'
:>> C = imfuse(A,B,'ColorChannel','red-cyan'), >> imwrite(C,'RedCyanSeagulls.jpg'),
With this example, you have started to get a grasp on some of the powers of MATLAB that are really easy to use. The only thing that we really did was to pick two pictures with the same size, very similar backgrounds, and non-overlapping (or to be more precise, minimally overlapping) objects in them and blend them using several ready-made choices of the function pair imshowpair-imfuse
. Once we were happy with the result, we saved it in a new JPEG file using imwrite
.
Note that the predefined 'green-magenta'
and 'red-cyan'
choices for the color channels can also be accomplished using the [R G B] triplets. The first one is [2 1 2], meaning that red and blue (magenta) were used for the second image and green was used for the first image. The second one is [1 2 2], meaning that green and blue (cyan) were used for the second image, while red was used for the first image. It's time for you to try out some of this now, so that you create a work of art with four different versions of the seagull composite picture.
In this exercise, you should try to create four different false-color composite versions of the seagull pictures. Try whichever combinations of [R G B] that you wish and then concatenate the four images in order to make a large 2x2 grid that contains all of them.
Using the functions imread
, imfuse
, flipdim
, and cat
, you should be able to make a picture that looks like the following screenshot:
This was not exactly difficult, right? Of course, your choices in tweaking the result are almost unlimited, since only your imagination can dictate what choices you would like to make in designing a work of art. You are free to try other choices of inputs, as well as applying various filters on your results to see what happens.
In this exercise, you created a quite interesting visual result using just two plain images. Playing with the falsecolor
method setting and different mixtures of the three color channels, led to four different variations of the blended image. Flipping two of the images along the vertical axis led to a more symmetrical outcome. You could experiment with other kinds of transformations, such as rotation, to further customize your resulting image.