Borrar filtros
Borrar filtros

Cylinder unwrapping with imtransform

2 visualizaciones (últimos 30 días)
Elisa
Elisa el 18 de Sept. de 2014
Respondida: Elisa el 19 de Sept. de 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 comentario
Image Analyst
Image Analyst el 18 de Sept. de 2014
How about attaching '2258.jpg' so people can try your code?

Iniciar sesión para comentar.

Respuesta aceptada

David Young
David Young el 18 de Sept. de 2014
Editada: David Young el 18 de Sept. de 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]

Más respuestas (2)

Elisa
Elisa el 19 de Sept. de 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 comentario
David Young
David Young el 19 de Sept. de 2014
Hard to know - maybe if you attach the image as suggested by Image Analyst it might be possible to figure it out.

Iniciar sesión para comentar.


Elisa
Elisa el 19 de Sept. de 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{:});

Categorías

Más información sobre Feature Detection and Extraction en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by