Hi, i´m a newbie in matlab. I´m tring to get a cilindrical projection of a planar image. The code is with this error "Error using projectIC (line 8) Not enough input arguments. ". I´m making some mistake inserting the image input, I1 (matrix), on the rgb2gray function I suppose. Can you help me? Thank you the code is the following:
% I1=imread('i1.bmp');
imshow(I1)
angle=33;
%
function [imageC] = projectIC(I1,angle)
ig = rgb2gray(I1);
[h w] = size(ig);
imageC = uint8(zeros(h,w));
alpha = angle/180*pi;
d = (w/2)/tan(alpha);
r = d/cos(alpha);
for x = -w/2+1:w/2
for y = -h/2+1:h/2
x1 = d * tan(x/r);
y1 = y * (d/r) /cos(x/r);
if x1 < w/2 && x1 > -w/2+1 && y1 < h/2 && y1 > -h/2+1
imageC(y+(h/2), x+(w/2) ) = ig(round(y1+(h/2)),round(x1+(w/2)));
end
end
end

댓글 수: 2

@João Martinho Marques: do NOT attach code as an image. We cannot search for text in an image, we cannot edit an image, we cannot run an image, we cannot fix an image... if you have code then it is text, so please either include it in your question as text or upload it as a text file.
OK! I had modified the code to the text format! Thanks

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

 채택된 답변

Jan
Jan 2017년 5월 9일
편집: Jan 2017년 5월 9일

0 개 추천

Your function projectIC requires 2 inputs according to the definition:
function projectIC(I1, angle)
Then you have to provide these arguments, when you call the function:
projectIC(I1, angle)
With calling projectIC only, the arguments are missing and the rgb2gray does not have an input.

댓글 수: 3

I had defined the variables on the workspace with the first part of the code. It´s not enough to provide the arguments to the function?
I1=imread('i1.bmp');
imshow(I1)
angle=33;
Jan
Jan 2017년 5월 9일
편집: Jan 2017년 5월 9일
No, having the variabvles in the workspace is not enough. See this example for a function:
x = 1.2;
y = 0.1;
sin % FAILS!
Here sin is called without inputs also and Matlab cannot guess, if you want the sin of x or of y. Your case is exactly the same, althozugh you use the same names for the variables in the definition of the function and in the command window. But this does not matter, because the names inside function are completely independent. The implementation of sin() can be:
function StandardOutput = sin(AbsurdInputName)
And if you call the sin function you will not have to consider the internal names in any way. This is the nature and the purpose of functions: Hide the internal details such that the function can be used without needing to know, what's going on inside.
And in your case this means, that you have to call the function with input arguments:
projectIC(I1, angle)
Or if you use different names:
ImageOne = imread('i1.bmp');
angleAroundAxis = 33;
projectIC(ImageOne, angleAroundAxis)
Thank you! Problem solved.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Code Analysis에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by