I am trying to "concatenate" some image files in a manner similar to either the montage or imtile functions, however, I need to be able to do this in vanilla matlab r2018a. The resulting image does not need to be displayed; it only needs to be created. I found this post How can I create a montage of images without using the montage function and I tweaked it to the following:
img1 = imread('<filename1>.png');img2 = imread('<filename2>.png');img3 = [img1 img2];imshow(img3);saveas(gcf, 'concatimg.png');
However, I have two problems which I am not sure how to remedy:
- How can I concatenate images of arbitrary size? E.g., if img1 is 300×300 and img2 is 250×325 is there some function to just add some "buffer" pixels or do I need to manually resize the images (or should I just be using subplot)? Also, how can I add buffer pixels surrounding my images as in this example (taken from the imtile documentation):
2. How can I save the composite image without the imshow and saveas function calls?
Best Answer