필터 지우기
필터 지우기

Cylinder unwrapping with imtransform

조회 수: 2 (최근 30일)
Elisa
Elisa 2014년 9월 18일
답변: Elisa 2014년 9월 19일
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
Image Analyst
Image Analyst 2014년 9월 18일
How about attaching '2258.jpg' so people can try your code?

댓글을 달려면 로그인하십시오.

채택된 답변

David Young
David Young 2014년 9월 18일
편집: David Young 2014년 9월 18일
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
Youssef  Khmou
Youssef Khmou 2014년 9월 18일
is it arcsin or asin ( or asind) ?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

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

댓글을 달려면 로그인하십시오.


Elisa
Elisa 2014년 9월 19일
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{:});

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by