Position based image stitching
Mostrar comentarios más antiguos
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!
Respuesta aceptada
Más respuestas (2)
Adam Rauff
el 23 de Mzo. de 2018
Editada: Adam Rauff
el 23 de Mzo. de 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 comentario
Timothy Sawe
el 5 de Dic. de 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
el 17 de Jul. de 2017
0 votos
Declare an image with the final size and register each of the four images according to your layout to the final image.
Categorías
Más información sobre 영상의 산술 연산 en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!