An open exchange for the MATLAB and Simulink user community |
Hosted by The MathWorks |
|
| Related Topics |
| New Products | Support | Documentation | Training | Webinars | Jobs | Newsletters |
| Problems? Suggestions? Contact us at files@mathworks.com | © 1994-2008 The MathWorks, Inc. Trademarks Privacy Policy |
I have a couple of questions regarding the size and techniques using the imagesc function. I would like to know first of all the actual size of the resulting image, for instance if my original image has 240 rows times 24000 columns, will it be reduced to fit the imagesc default size? And if so, how does Matlab do it? Which points does it take away and which will it keep?
I have looked for a while but I have not been able to find any answers, I hope it isn´t such stupid question.
Thank you very much for your time.
Pia—imagesc simply scales the image to fit into the current axes. If there’s no figure currently open, a figure gets created at the default size, and the image gets plotted into an axes inside that figure, also at the default size. Nearest-neighbor interpolation is used. If you want more scaling control, try using the Image Processing Toolbox function imtool.
Thank you for your help and for responding so quickly.
If I may, I have another question: I am making a ‘custom’ spatial transformation and I am using pol2cart and cart2pol as the forward and inverse functions. I get the following error message:
??? Undefined function or method ‘atan2′ for input arguments of type ’struct’.
Error in ==> cart2pol at 22
th = atan2(y,x);
Error in ==> maketform>inv_composite at 584
U = feval(t.tdata(i).inverse_fcn, U, t.tdata(i));
Error in ==> images\private\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 273
B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, …
Error in ==> rphi2xy_imtransf at 76
Z = imtransform(absd_chiqui,TFORM, ‘UData’,udata,’VData’,vdata,’XData’,xdata,’YData’,ydata);
My code is like this:
dims_IN = 2;
dims_OUT = 2;
FRWD_FCN = @pol2cart;
INV_FCN = @cart2pol;
TDATA = [];
TFORM = maketform(’custom’,dims_IN, dims_OUT, FRWD_FCN,INV_FCN,TDATA);
udata = [range_start range_end];
vdata = [-angle_w/2 angle_w/2];
xdata = [range_start range_end];
ydata = [range_end*sin(angle_w/2) -range_end*sin(angle_w/2)];
Z = imtransform(absd_chiqui,TFORM, ‘UData’,udata,’VData’,vdata,’XData’,xdata,’YData’,ydata);
Initially I did not write any UData, VDAta, XData or YData and I got this error message:
XData and YData could not be automatically determined.Try specifying XData and YData explicitly in the call to IMTRANSFORM.
So I guess my question is: isn´t it possible to use such functions for a custom transformation, or is my problem in the TFORM definition?
Thank you again for your time,
Pia
Pia—It looks to me like you have an ordinary debugging problem to solve. Your error message is telling you that a struct value, instead of a numeric value, is being passed into cart2pol. Set a breakpoint - dbstop if error - run the code, and then look up and down the function call stack to see if you can understand which variables contain values you don’t expect, and why. You might try first to see if you can get your custom tform struct to work with tforminv. If that doesn’t work, there’s no way imtransform can use it.
Thank you very much, I will try what you propose.
This is an unrelated question but concerns the image processing toolbox. I am using a site license for the Naval Undersea Warfare Center in Newport RI. I am trying to do some generic affine transformations but keep getting errors. So I went to the help section for imtransform and copied and pasted the code that was there as an example and still get the same error:
>> I = imread(’cameraman.tif’);
tform = maketform(’affine’,[1 0 0; .5 1 0; 0 0 1]);
J = imtransform(I,tform);
imshow(I), figure, imshow(J)
??? Error using ==> imtransform>parse_inputs at 440
XData and YData could not be automatically determined.Try specifying XData and YData explicitly in the call to IMTRANSFORM.
Error in ==> imtransform at 262
args = parse_inputs(varargin{:});
Now of course I can enter xdata and ydata to map the old image to the new one but why am I getting this error on an example?
Thanks,
John
John—That’s a puzzle. Normally, you might get this error message when using a tform struct containing only an inverse mapping and no forward mapping. In that case, imtransform uses an iterative optimization procedure to try to find the output spatial bounds, and sometimes that procedure can fail to find a solution. But that shouldn’t happen for affine, for which it is easy to compute both the forward and the inverse mapping. I can run the example OK using R2007b on Windows. Why don’t you send me your version and platform information, and I’ll follow up with you further by e-mail.
John and I worked out his problem via e-mail. It turned out to be extraneous functions on his path.