How to use maketform custom option

3 visualizzazioni (ultimi 30 giorni)
Molly
Molly il 9 Giu 2016
Commentato: Molly il 9 Giu 2016
Hello,
I am trying to create a tform to transform image 2 to image 1. Image 2 is a frame from a video that is after a time has passed so there is slight variation. I need to create a tform so I can then use imtransform. Basically, I need to solve the matrix equation A = XB for X to determine the transition matrix. Right now I have the matches and the scores between the two images by using the vl_ubcmatch function. I am struggling to get the equation for the inverse mapping variable to use in the 'custom' setting on maketform. Here is the code I have to calculate the transformation matrix:
% Compute Transformation Matrix (A=XB+Y)
% A/B = x
size_d1 = 1:size(d1,2);
%X = (size_d1')/location(:);
f = @(x,unused) (size_d1/x);
ndims_in = 2;
ndims_out = 2;
forward_mapping = [];
inverse_mapping = f;
tdata = [];
transform_matrix = maketform('custom', ndims_in, ndims_out,...
forward_mapping, inverse_mapping, tdata);
When I run this code, and send the transform_matrix tform into imtransform function, I get these errors:
Error using /
Matrix dimensions must agree.
Error in @(x,unused)(size_d1/x)
Error in maketform>inv_composite (line 540)
U = feval(t.tdata(i).inverse_fcn, U, t.tdata(i));
Error in tform (line 55)
X = feval( t.(f.fwd_fcn), U, t );
Error in tforminv (line 67)
varargout = tform('inv', nargout, varargin{:});
Error in tformarray (line 217)
M = tforminv(G,T);
Error in imtransform (line 276)
B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, ...
Error in Patterson_Project2 (line 81)
new_image2 = imtransform(I2, transform_matrix,'XData', xdata, 'YData', ydata);
Thanks for your help!

Risposte (1)

Walter Roberson
Walter Roberson il 9 Giu 2016
@(x,unused)(size_d1./x) %notice ./ not /
  1 Commento
Molly
Molly il 9 Giu 2016
I got the same error when trying this. I'm not even sure if my equation for the inverse function is correct. How would you set up the inverse equation for A = XB to use in the maketform function?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by