[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Open an Image file into axes in Matlab V7.0.1

Posted on 2009-02-22
13
Medium Priority
?
1,824 Views
Last Modified: 2016-02-10
Hi all I need code to open an image file from my computer into an axes in Matlab, what I need is something that can bring up a file explorer and there i can choose a file.

Thanks
0
Comment
Question by:MzeeSimba
  • 7
  • 4
  • 2
13 Comments
 
LVL 15

Expert Comment

by:yuk99
ID: 23707884
Try this code. You can specify your file mask as an argument of uigetfile.
[filename, pathname] = uigetfile('');
image(imread(fullfile(pathname,filename)));

Open in new window

0
 

Author Comment

by:MzeeSimba
ID: 23708569
Thanks Yuk99, how about the bit to place the image into an axes? Is it possible  to resize the image to fit in the axes? I dont want the axes to change size but rather the image to change size and fit in the axes.  

Thanks
0
 
LVL 15

Accepted Solution

by:
yuk99 earned 2000 total points
ID: 23708671
IMAGE function will fit the axes (in opposite to imshow). But default it uses current axes or create a new one. You can specify on which axes to plot the image:
a1=axes;
image(imread(fullfile(pathname,filename)),'Parent',a1);

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:yuk99
ID: 23708699
Instead of using 'Parent' you can also just change the current axes with axes(a1).
0
 

Author Comment

by:MzeeSimba
ID: 23708705
Thank you very much, sorry am really a newbie.

One last problem, its also creating a new axes that i dont need, how can i remove that?

Thanks Yuk99
0
 

Author Comment

by:MzeeSimba
ID: 23708731

Here is what I have done.

[filename, pathname] = uigetfile('*.jpg');
    image(imread(fullfile(pathname,filename)));
    ax=axes
 image(imread(fullfile(pathname,filename)),ax);
0
 

Author Comment

by:MzeeSimba
ID: 23708802
OK I have sorted that, just removes the ax=axes.

Thank you so much.
0
 
LVL 5

Expert Comment

by:LukeyJay
ID: 23711016
Seems to me like the user offered 500 points for the question and wants to close it by accepting their own solution even though they got excellent advice from yuk99.  In my opinion, this isn't fair.

Luke
0
 

Author Comment

by:MzeeSimba
ID: 23711263
How did I do that LukeyJay? Do you mean I offered myself these 500 points? How can that happen?

I was trying to give yuk99 points for the two solutions he provided to me, why should I give myself points? Please let me know how to reverse this, if its what I did.
0
 
LVL 15

Expert Comment

by:yuk99
ID: 23713357
LukeyJay, MzeeSimba, thank you.
0
 

Author Comment

by:MzeeSimba
ID: 23713413
yuk99 is there a way I can give you the points coz I didnt give these to myself and I dont even know how this happened, if it did. i dont even know how to check for this, please am sorry am new to this service.

If there is a way or if u can give me a nother kind of solution, so I can forward these points, I will be very happy to do that coz u really deserve all the points I can give you for the help you gave me.
0
 
LVL 5

Expert Comment

by:LukeyJay
ID: 23714314
I think you got it straight, but originally, the notice said you wanted to close the question, selecting your own response as the correct response and giving yuk99 20 points each for two of his posts as "assisted" solutions.  But by selecting his response as the accepted response as you have, I think you've got it right.  Didn't mean to interfere.

Luke
0
 

Author Comment

by:MzeeSimba
ID: 23715112
Not at all LukeyJay, yo not interfering am greatful you noticed mt error. yuk99 deserves points for the help. I hope I have corrected my mistake.

Thank you yuk99 and thank you LukeyJay.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question