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

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

2 Kommentare

@vani shree: please tell us the exact outputs from these commands:
size(image1)
size(image2)
sir it does not show any output. but my input file of image1 and image 2 is

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

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)

19 Kommentare

sir i get rid of that error. but again one more error like " error using horzcat dimensions of matrics being concatenated are not consistent." error in I12 = [I1 I2] ; line
What are sizes of I1 and I2 ?
I1 size is 37 kb and 234*234 dimension I2 size is 32.7kb and 236*234 dimension
@vani shree: the two images have different numbers of rows, therefore cannot be concatenated horizontally.
I said that, you can get them to same dimensions to join..I have given it in code..you accepted the answer and situation came to the question.
sir i acccept that answer but still it is showing me the same error. please guide me sir. im new to matlab. wat do i do now? can i give the same size of image?
same error i m getting sir" Error using horzcat Dimensions of matrices being concatenated are not consistent."
I12 = [I1 I2] ; in this line
Attach the images with which you have tried the above code.
good evening sir. origanal image will be my I1 and fake image will be my I2. sir i have attached my two images.
my code is
% code
function im = appendimages(image1, image2)
if numel(image1)>numel(image2)
image2 = imresize(image2,[size(image1,2) size(image1,2)]);
else
image1 = imresize(image1,[size(image2,1) size(image2,2)]);
end
im = [image1 image2];
figure
imshow(im)
im = [image1 ; image2]; figure imshow(im)
this is my code sir. and i have attached sift function call code also thank you very much sir
<<
<<
>>
>>
sir please help me. i m doing project based on this code sir
I will answer tomorrow..Morning.
thank you so much sir
my project title is Identifying fake products by matching their logos based on context. only 50% coding i have done sir. still matching process is pending.
image1 = imread('FAKE.jpg') ;
image2 = imread('ORIGINAL.jpg') ;
if numel(image1)>numel(image2)
image2 = imresize(image2,[size(image1,1) size(image1,2)]);
else
image1 = imresize(image1,[size(image2,1) size(image2,2)]);
end
im = [image1 image2];
figure
imshow(im)
im = [image1 ; image2];
figure
imshow(im)
I am not getting any error.
sir did u gave fake and original imag ?
sir when i run this code separately i m getting correct output. the problem is when i add function and map that function in another code file i m getting error sir. can you help me sir
sir when i gave another image it is not running sir. it shows same error Error using horzcat Dimensions of matrices being concatenated are not consistent.
Hello...Are both files RGB? There is a small correction...copy the code now and run.
thank you sir.. its running successfully. thank you very much. you explained me well.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 22 Apr. 2017
A very general stitching app with a GUI is given here: http://www.mathworks.com/matlabcentral/fileexchange/25797-stitch

1 Kommentar

thank you sir for sharing this gui file. sir can u help me to run ASIFT code in matlab. i have tried but i dont know how to run this sir.

Melden Sie sich an, um zu kommentieren.

Kategorien

Gefragt:

am 20 Apr. 2017

Kommentiert:

am 23 Apr. 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by