How do you add an image to a plot?

조회 수: 8 (최근 30일)
Nicole
Nicole 2014년 5월 4일
답변: Image Analyst 2014년 5월 5일
In class we were told to add images to our plot and they gave us an example that worked like this:
url = 'http://www.inpayne.com/models/350e1.jpg';
img = imread(url);
himg = image([200,250],[200,250],img);
Only every time I use this on my plot I get the error message: "Attempt to call constructor image with incorrect letter case."
Does anyone know what could be causing this error? Thank you!
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2014년 5월 4일
The error that you are observing is similar to that found with imshow at the following link: error in imshow. There may be a conflict with an existing variable or folder named image which would require you to rename the variable or folder. If you type which image -all in the command window, what is returned? (The which command will return all variables and functions that have the image name.)
Nicole
Nicole 2014년 5월 5일
편집: Image Analyst 2014년 5월 5일
C:\Users\Nicole\Documents\MATLAB\image.m
built-in (C:\Program Files\MATLAB\R2013b\toolbox\matlab\specgraph\image)
This is what I got when using that command. It seems like it's coming from the toolbox. I'm not sure what to do with that.

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

답변 (2개)

Jan
Jan 2014년 5월 4일
편집: Jan 2014년 5월 4일
Check, which command or class is called:
which image -all
which Image -all
What do you get as output?
[EDITED - this is wrong:] I guess, that if you do not have the Image Processing Toolbox, but a user defined class called "Image", such a problem could appear. [ image does not belong to the Image Processing Toolbox!]

Image Analyst
Image Analyst 2014년 5월 5일
Here's what it says on my system (where your code works):
>> which -all image
built-in (C:\Program Files\MATLAB\R2014a\toolbox\matlab\specgraph\image)
Here's what it says on your system:
>> which -all image
C:\Users\Nicole\Documents\MATLAB\image.m
built-in (C:\Program Files\MATLAB\R2013b\toolbox\matlab\specgraph\image)
Note that you have an extra file. Take this file "C:\Users\Nicole\Documents\MATLAB\image.m", which is apparently something you wrote, and rename it.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by