Position based image stitching
Afficher commentaires plus anciens
I have 4 same size tile images and they are partially overlapped (assume 15% each).

I don't want to use stitching algorithms like feature based stitching but just array images in rectangle mold like above image.
Thanks!
Réponse acceptée
Plus de réponses (2)
Adam Rauff
le 23 Mar 2018
Modifié(e) : Adam Rauff
le 23 Mar 2018
This code generalizes this procedure to more than 2x2 (grayscale images only)
% define Y by X number of images
IMinfo.YXgrid = [10 8];
% chan4.IM is structure where images are stored in order
% i.e chan4(1).IM is image at the (1,1) position
% chan4(2).IM is image at the (1,2) position
% chan4(5).IM is image at the (2,1) position
% obtain final size of image
overlap = (Insert your overlap percentage);
[r, c] = size(firstImage);
overlap_c = round(overlap * c); % pixels
new_c = c*IMinfo.XYGrid(1) - (IMinfo.XYGrid(1)-1)*overlap_c; % total columns in final image
overlap_r = round(overlap * r); % pixels
new_r = r*IMinfo.XYGrid(2) - (IMinfo.XYGrid(2)-1)*overlap_r; % total rows in final image
% intialize mosaic template
Mosaic = zeros(new_r, new_c);
% "stitch" images by overlaying them
for i = 1:IMinfo.XYGrid(2)
roBegin = (i-1)*r + 1 - overlap_r*(i-1);
roEnd = (i-1)*r + r - overlap_r*(i-1);
for j = 1:IMinfo.XYGrid(1)
colBegin = (j-1)*c + 1 - overlap_c*(j-1); % in matlab index begins at 1
colEnd = (j-1)*c + c - overlap_c*(j-1);
Mosaic(roBegin:roEnd, colBegin:colEnd) = chan4(j+((i-1)*IMinfo.XYGrid(1))).IM;
end
end
1 commentaire
Timothy Sawe
le 5 Déc 2019
chan4(1).IM = imread('img1.jpg');
chan4(2).IM = imread('img2.jpg');
but it gives me an error:
Unable to perform assignment because the size of the left side is 1-by-6 and the size of the
right side is 2873-by-2825.
Error in pos_based (line 44)
Mosaic(roBegin:roEnd, colBegin:colEnd) = chan4(j+((i-1)*IMinfo.YXGrid(1))).IM;
I suspect I haven't inserted the images properly is why. How did you do it? P.S. They are in grayscale.
Don Zheng
le 17 Juil 2017
0 votes
Declare an image with the final size and register each of the four images according to your layout to the final image.
Catégories
En savoir plus sur 영상의 산술 연산 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!