# Addition of Two Images Using MATLAB Image Processing

In this tutorial, you will learn how to add two images. Yes, it is possible in MATLAB. You can add i.e. superimpose two images. Following are the steps to add two images using MATLAB image processing:

The only requirement for superimposition (or addition) of two images is that the two matrices that you have defined for two images should have the same size (as we know MATLAB totally works with matrices and the addition of two matrices is possible only when they are of the same size).

Let us consider two images

1. H: New photorock 1.jpg

2. H: New photoImagesPhoto1561.jpg

[caption id="" align="aligncenter" width="300"] H:New photorock 1.jpg[/caption]

[caption id="" align="aligncenter" width="225"] H:New photoImagesPhoto1561.jpg[/caption]

(These are two images that I have chosen, but for your case, it may be different. For copying the image path visit my previous post)

## MATLAB Program for Addition of Two Images:

`%Addition of two images%Created by : myclassbook.org (mayuresh)%Created on : 21 May 2013A=imread('H:New photorock 1.jpg');          %define A as a first imageB=imread('H:New photoImagesPhoto1561.jpg'); %define B as a second imageC=imresize(A,[400 400]);                    % image resize of A as 400*400 matrixD=imresize(B,[400 400]);                    % image resize of B as 400*400 matrix  E=imadd(C,D);                               % image addtion of C and Dimshow(E)                                   % display of image E`

[caption id="" align="aligncenter" width="490"] Addition of Two Images[/caption]

## Output

[caption id="" align="aligncenter" width="490"] Addition of Two Images[/caption]