Effacer les filtres
Effacer les filtres

Using imregister and imregtform to stitch overlapping images

9 vues (au cours des 30 derniers jours)
Todd Fallesen
Todd Fallesen le 29 Juil 2020
Modifié(e) : Todd Fallesen le 21 Déc 2021
I'm trying to stich together two tiled images that have 15% overlap. Using imregister on the overlap sections, I get a good registration of those overlap sections, but when I multiply the whole image by the tform from imregtform, I don't get a translation.
In figure 3, I'm showing the pair of images before registration, figure 5 after registration, and then in figure 8, I'm using the tform I get from imregtform to 'warp' (in this case translate) the image. I can't figure out why in my figure 8, the image isn't registering properly. It also doesn't register if I multiply the overlap region from the moving image by the tform.
If anyone has any ideas, I'm sure it's something easy that I've been dancing around.
Thanks!
[optimizer, metric] = imregconfig('monomodal')
tform = imregtform(moving, fixed, 'translation', optimizer, metric);
movingRegistered = imregister(moving, fixed, 'translation', optimizer, metric);
moved = imwarp(moving, tform); %make the moved image
big_moved = imwarp(scaled_f2, tform);
%%
figure(3)
imshowpair(fixed, moving,'Scaling','joint')
figure(5)
imshowpair(fixed, movingRegistered)
figure(8)
imshowpair(fixed, big_moved)
  2 commentaires
Andrea Jacobson
Andrea Jacobson le 21 Déc 2021
Hi! Did you ever figure out what your problem was with the image registeration? If so, can you share some of your scripts for this? I am trying to do some 3D image stiching and need help.
Todd Fallesen
Todd Fallesen le 21 Déc 2021
Modifié(e) : Todd Fallesen le 21 Déc 2021
Hi Andrea, in the end I pulled the x and y distances out of the matrix, here's a function I made for it. Keep in mind, this is an old copy I have on my laptop, and you probably don't want to do what I did here and put in hard coded limits for images :-)
function [translate_distance] = Find_Translation_distance(image_1, image_2, direction, x_dim_tile, y_dim_tile, overlap)
switch direction
case 'x'
leeway = overlap*0.1*x_dim_tile; %the amount we let it move max
overlap_coord = round(x_dim_tile*overlap); %define the nominal overlap section in x
%generate the overlap sections to align
fixed = image_1(:,end-overlap_coord:end);
moving = image_2(:,1:overlap_coord); %move the second image over the first
[optimizer, metric] = imregconfig('monomodal');
tform = imregtform(moving, fixed, 'translation', optimizer, metric); %set up the image translation metric
tform.T;
x_trans = [1 0 1]*tform.T; %matrix multiplication to pull out the transformation matrix
x_trans = overlap_coord - x_trans(1);
if x_trans < 1
x_trans = 1; %how many pixels we're moving in x
end
if x_trans > 249.5235 || x_trans < 182.9617
x_trans = 216.2426; %give a hard set on the max number of pixels we can move.
disp('Hit offset max');
end
translate_distance = x_trans;
x_disp = strcat('x translate distance is: ',num2str(translate_distance));
disp(x_disp);
case 'y'
leeway = overlap*0.1*y_dim_tile; %the amount we let it move max
overlap_coord = (y_dim_tile*overlap); %define the nominal overlap section in y
%generate the overlap sections to align
fixed = image_1(end-overlap_coord:end,:);
moving = image_2(1:overlap_coord,:); %move the second image over the first
[optimizer, metric] = imregconfig('monomodal');
tform = imregtform(moving, fixed, 'translation', optimizer, metric); %set up the image translation metric
tform.T;
y_trans = [0 1 1]*tform.T;
y_trans = overlap_coord - y_trans(1); %how many pixels we're moving in y
if y_trans > 249.5235 || y_trans < 182.9617
y_trans = 216.2426; %give a hard set on the max number of pixels we can move.
disp('Hit offset max');
end
translate_distance = y_trans;
y_disp = strcat('y translate distance is: ',num2str(translate_distance));
disp(y_disp);
end
end

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by