Concatenating images from image files
48 views (last 30 days)
Hello! I have a series of images saved in a folder, and I have written a short program to open two of these image files, concatenate them (preferably vertically, although for now I am trying horizontally), then save this new image to the same folder. This is what I have written so far:
%this is the folder where the original images are located path='/home/packremote/SharedDocuments/Amina/zEXAMPLE/';
file1 = strcat(cr45e__ch_21', '.pdf');
[image1,map1] = imread(graph1);
file2 = strcat('cr45f__ch_24', '.jpg');
[image2,map2] = imread(graph2);
image1 = ind2rgb(image1,map1);
image2 = ind2rgb(image2,map2);
image3 = cat(2,image1,image2);
%this is the directory where I want to save the new images
nombrejpg=strcat(dircase, 'test', jpgext)
saveas(f, nombrejpg, 'jpg')
However, I keep getting an error that my files do not exist, though I am certain the names are copied correctly.
I am currently using jpg files, but the format can be easily converted.
Any input on how to fix this error, or a nicer way of preforming this task is greatly appreciated!
Walter Roberson on 27 May 2011
iwidth = max(size(image1,2),size(image2,2));
if size(image1,2) < iwidth
image1(1,iwidth,1) = 0;
if size(image2,2) < iwidth
image2(1,iwidth,1) = 0;
image3 = cat(1,image1,image2);
More Answers (2)
Harsha Vardhan Rao Avunoori on 27 May 2011
Are you specifying the proper directory/path when you are executing your code ? Can you please post the exact error so that it would be a little bit easier to understand what's causing you trouble.