MATLAB: Error using vertcat Dimensions of matrices being concatenated are not consistent.

image processing

sir i m getting this error i dont know how to rectify it please help me
%%appendimages
% im = appendimages(image1, image2)
%
% Return a new image that appends the two images side-by-side.
function im = appendimages(image1, image2)
% Select the image with the fewest rows and fill in enough empty rows
% to make it the same height as the other image.
rows1 = size(image1,1);
rows2 = size(image2,1);
if (rows1 < rows2)
image1(rows2,1) = 0;
else
image2(rows1,1) = 0;
end
% Now append both images side-by-side.
im = [image1 ; image2] %%in this line im getting error.
thanks with regards

Best Answer

Instead of adding extra zeros, you can resize the images to same dimensions. you may consider the following:
I1 = imread('ORIGINAL1.jpg') ;
I2 = imread('FAKE.jpg') ;
if numel(I1)>numel(I2)
I2 = imresize(I2,[size(I1,1) size(I1,2)]) ;
else
I1 = imresize(I1,[size(I2,1) size(I2,2)]) ;
end
I12 = [I1 I2] ;
figure
imshow(I12)
I12 = [I1 ; I2] ;
figure
imshow(I12)
Related Question