why does it give the error undefined function?

4 次查看(过去 30 天)
Hi all,
I have written this code but when I run the code it gives the error
"Undefined function or variable imageX"
It is not my first time writing a code and I have other codes working properly except this one. Could someone help me figure out the problem?
here is the code I wrote:
function imageOut = imageX(imageIn,object);
jpgImage = imread(imageIn);
spaceRow = size(object,1)-size(jpgImage,1);
spaceAbove = round(spaceRow/2);
spaceBelow = spaceRow - spaceAbove;
jpgImage1 = [255.*ones(spaceAbove,size(jpgImage,2),size(jpgImage,3));jpgImage;255.*ones(spaceBelow,size(jpgImage,2),size(jpgImage,3))];
spaceColumn = size(object,2)-size(jpgImage,2);
spaceRight = round(spaceColumn/2);
spaceLeft = spaceColumn - spaceRight;
imageOut = [255.*ones(size(jpgImage1,1),spaceLeft,size(jpgImage,3)),jpgImage1,255.*ones(size(jpgImage1,1),spaceRight,size(jpgImage,3))];
imwrite(imageOut,'imageOut.jpg');
end
  3 个评论
Image Analyst
Image Analyst 2017-12-25
To put 255 around your image, why not use padarray()?
Walter Roberson
Walter Roberson 2017-12-25
K.G. comments to Image Analyst:
thanks I did not know about this function

请先登录,再进行评论。

采纳的回答

help_me
help_me 2017-12-25
Since it's a function you can't actually run it by pressing F9 or the green arrow. You have to call it from the command window.
In this case it would be something like:
whatever_your_file_name_is(Input_for_imageIn,Input_for_object)
and hopefully that should work, let me know if it doesn't
Best of luck
  1 个评论
Walter Roberson
Walter Roberson 2017-12-25
Although it is true that you cannot just press F9 or the green arrow to run the code successfully, the error message would have been different in such a case: it would have been an error about an undefined input value rather than an error about the function not being found.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by