フィルターのクリア

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 Center および File ExchangeFeature Detection and Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by