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!