Sanvee Prajapati
Sanvee Prajapati

Reputation: 13

how to concatenate two images vertically in matlab?

>> a=imread ('Vasculature.tif');
>> b = imresize (a, [400,400]);
>> c=imread ('activation.tif');
>> d= imresize (c, [400,400]);
>> e=imadd (b,d); 

the code I was able to work with was for horizontal concatenation pls do tell me concatenating the image vertically..

Upvotes: 1

Views: 2816

Answers (2)

rayryeng
rayryeng

Reputation: 104464

Alternatively, you can use cat:

c = cat(1, a, b);

You can also use straight MATLAB matrix building:

c = [a; b];

This is assuming that the images have the same number of columns. Doing c = [a b] concatenates matrices column-wise. If you want to do it by row, use the semi-colon. Take a look at this basic tutorial on MATLAB operations here to get you started: http://www.mathworks.com/help/matlab/examples/basic-matrix-operations.html

Upvotes: 0

user1178540
user1178540

Reputation:

Get the images and make a matrix of them, use for matrix a and matrix b,

c = vertcat(a,b)

Upvotes: 1

Related Questions