Position based image stitching
显示 更早的评论
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!
采纳的回答
更多回答(2 个)
Adam Rauff
2018-3-23
编辑:Adam Rauff
2018-3-23
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 个评论
Timothy Sawe
2019-12-5
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
2017-7-17
0 个投票
Declare an image with the final size and register each of the four images according to your layout to the final image.
类别
在 帮助中心 和 File Exchange 中查找有关 영상의 산술 연산 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!