Effacer les filtres
Effacer les filtres

Cylinder unwrapping with imtransform

2 vues (au cours des 30 derniers jours)
Elisa
Elisa le 18 Sep 2014
Réponse apportée : Elisa le 19 Sep 2014
Hello everybody, I am trying to make the unwrapping of a photo of a cylindrical object (only one side), I applied this code I wrote:
if true
% code
I = imread('2258.jpg');
axis on
box on
imshow(I)
ndims_in = 2;
ndims_out = 2;
forward_mapping = []
f = @(x, unused) arcsin(1/x);
inverse_mapping = f;
tdata = [];
tform = maketform('custom', ndims_in, ndims_out, ...
forward_mapping, inverse_mapping, tdata);
udata = [-1 1];
vdata = [-1 1];
xdata = [-1.57 1.57];
ydata = [-1 1];
I2 = imtransform(I, tform, 'UData', udata, 'VData', vdata, ...
'XData', xdata, 'YData', ydata);
subplot(1,2,1)
imshow(I)
subplot(1,2,2)
imshow(I2)
end
but I received lots of errors: ??? Error using ==> mldivide Matrix dimensions must agree.
Error in ==> @(x,unused)arcsin(1/x)
Error in ==> maketform>inv_composite at 592 U = feval(t.tdata(i).inverse_fcn, U, t.tdata(i));
Error in ==> tform at 56 X = feval( t.(f.fwd_fcn), U, t );
Error in ==> tforminv at 68 varargout = tform('inv', nargout, varargin{:});
Error in ==> tformarray at 241 M = tforminv(G,T);
Error in ==> imtransform at 275 B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, ...
Where is the error for you? How could I solve it? Thank you a lot, Phalaen
  1 commentaire
Image Analyst
Image Analyst le 18 Sep 2014
How about attaching '2258.jpg' so people can try your code?

Connectez-vous pour commenter.

Réponse acceptée

David Young
David Young le 18 Sep 2014
Modifié(e) : David Young le 18 Sep 2014
I haven't tested this, but here's a quick thought: try replacing
f = @(x, unused) arcsin(1/x);
with
f = @(x, unused) asin(1./x);
as you probably want the element-by-element division rather than the matrix inverse here.
[Edit: arcsin replaced with asin to take note of Youssef Khmou's helpful comment]
  1 commentaire
Youssef  Khmou
Youssef Khmou le 18 Sep 2014
is it arcsin or asin ( or asind) ?

Connectez-vous pour commenter.

Plus de réponses (2)

Elisa
Elisa le 19 Sep 2014
Thank you David and Youssef, with your suggestion (f = @(x, unused) asin(1./x);) matlab gave no error messages, the problem now is that, after the computation, it returns a completely black image and not the stretched image, what could the problem be? Thank you!
  1 commentaire
David Young
David Young le 19 Sep 2014
Hard to know - maybe if you attach the image as suggested by Image Analyst it might be possible to figure it out.

Connectez-vous pour commenter.


Elisa
Elisa le 19 Sep 2014
I found another problem, that I corrected: It is not f = @(x, unused) asin(1./x); but f = @(x, unused) asin(x); (I made an error in the geometrical computation), but now I received another declaration by Matlab: ??? Error using ==> imtransform>check_udata at 606 'UData' elements cannot be equal unless A has only one column.
Error in ==> imtransform>parse_inputs at 386 args.udata = check_udata(varargin{k+1}, args.A);
Error in ==> imtransform at 264 args = parse_inputs(varargin{:});

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by