Trying to display four color images together but can't figure out the placement
6 views (last 30 days)
Show older comments
So I'm trying to combine four 300 x 400 x 3 pixel color images into a "2x2 grid" (two next to each other, and the other two right below those). An example image for how it's supposed to look is shown at the bottom. I started with a blank matrix of zeros, and I'm trying to fill each "spot" with the images. I'm also supposed to have a 10 pixel sized separation between the images (only in the center. if you look at the image you can see the separation as black lines in the center). This is what I have so far and don't know how to place the last 2 images. I'm not even 100% sure why the eiffel tower image shows up on the bottom right rather than to the right of the street image. Sorry if this is confusing...here's what I have so far:
fullImg = zeros(300*2+10,400*2+10,3,'uint8'); %matrix of zeros with double the length of x and y, plus 10 for the separation
fullImg(1:300,1:400,:) = img1; %fill the first "spot" with image 1
fullImg(311:610,411:810,:) = img2; %fill the second "spot" with image 2...not sure why this is in the bottom right
figure, imshow(fullImg);
How the image is supposed to look in the end:

0 Comments
Answers (1)
KSSV
on 30 Jan 2019
I1 = imread(image1) ;
I2 = imread(image2) ;
I3 = imread(image3) ;
I4 = imread(image4) ;
% Get all images to this dimensions
m = 500 ; n = 500 ; p = 3 ;
% resize all images to same
I1 = imresize(I1,[m,n]) ;
I2 = imresize(I2,[m,n]) ;
I3 = imresize(I3,[m,n]) ;
I4 = imresize(I4,[m,n]) ;
I = [I1 I2 ; I3 I4] ;
imshow(I)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!