Concatenating images from image files
이전 댓글 표시
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:
function concatentateImages
%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
dircase=('/home/packremote/SharedDocuments/Amina/zEXAMPLE/');
nombrejpg=strcat(dircase, 'test', jpgext)
saveas(f, nombrejpg, 'jpg')
fclose('all');
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!
Cheers,
Amina
채택된 답변
추가 답변 (2개)
Harsha Vardhan Rao Avunoori
2011년 5월 27일
0 개 추천
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.
댓글 수: 4
A
2011년 5월 27일
Walter Roberson
2011년 5월 27일
[image1,map1] = imread(file1); %not graph1 !!
A
2011년 5월 27일
Walter Roberson
2011년 5월 27일
Your line
file1 = strcat(cr45e__ch_21', '.pdf');
should be
file1 = strcat('cr45e__ch_21', '.pdf');
However, without that, the code would not have reached as far as reading the file.
Please post your current code.
Gowtham N
2016년 3월 10일
0 개 추천
Hello. I want to read many images from a folder and want to concatinate the same in horizontal,how to do this with for loop?
댓글 수: 1
Image Analyst
2016년 3월 11일
to stitch images together horizontally, use a comma:
wideImage = [image1, image2];
You can find a more general stitch program in the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/25797-stitch
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!