Infusing/ Overlaying two images in reference to their center-to-center distance w.r.t to coordinates

2 views (last 30 days)
I am working on merging/ infusing/ overlaying images w.r.t coordinate values. I am able to find distance between two coordinate points and using that reference I want to infuse them. Following I have acheived:
% Distance btw image 1 & 2
A = imread('0.JPG');
Picinfo0 = imfinfo('0.JPG');
X0= dms2degrees(Xx0);
Y0= dms2degrees(Yy0);
B = imread('1.JPG');
Picinfo1 = imfinfo('1.JPG');
X1= dms2degrees(Xx1);
Y1= dms2degrees(Yy1);
wgs84 = wgs84Ellipsoid("m");
D0 = distance(X0,Y0,X1,Y1,wgs84) % D in meters , this D is c/c distance between two images
% Pixel info for Image 1
% Pixel Size=tan(FOV/2)*Distance/pixel width ;;; Pixel Size Formula
FOV=82.9 % from DJI website
DD0=str2double(Picinfo0.XMPData.drone_dji.RelativeAltitude) % Altitude value is Character array
pixelsize0w=tan(FOV/2)*DD0/Picinfo0.Width % meters
%pixelsize0h=tan(FOV/2)*DD0/Picinfo0.Height % meters
R0 = imref2d(size(A),pixelsize0w,pixelsize0w)
%Pixel info for Image 2
DD1=str2double(Picinfo1.XMPData.drone_dji.RelativeAltitude) % Altitude value is Character array
pixelsize1w=tan(FOV/2)*DD1/Picinfo1.Width % meters
%pixelsize1h=tan(FOV/2)*DD1/Picinfo1.Height % meters
R1 = imref2d(size(B),pixelsize1w,pixelsize1w)
% Referencing Image 1 & 2
% Set referencing object parameters to specify the limits of the coordinates in world coordinates.
R0.XWorldLimits = R1.XWorldLimits
R0.YWorldLimits = R1.YWorldLimits+D0 % D is distance between two coordinates
Here in attained figure AB, the overlap is starting after 'D0' (2.5 meters) from the bottom of 0.JPG as reference. How can I set 'D0' as center to center distance between two images. Kindly assist and advise.

Accepted Answer

Image Analyst
Image Analyst on 23 Nov 2023
You're going to have to create a canvas larger than either one, like the height is the sum of the two images heights. Paste one image onto the canvass. Then compute the shift and paste the second image on. Or you can average it instead of pasting. See attached example.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!