how i can upload a picture using gui when i push a pushbutton

33 visualizaciones (últimos 30 días)
sajid ali
sajid ali el 11 de Mayo de 2013
Editada: priyatham b el 24 de Mzo. de 2017
i want in gui that is there is a pushbutton name ,upload, and when i push it then it will automatically open a folder from where i want to add any image
  1 comentario
priyatham b
priyatham b el 24 de Mzo. de 2017
Editada: priyatham b el 24 de Mzo. de 2017
[filename, pathname] = uigetfile('*.*','D:\Users\Public\Pictures\Sample Pictures');
img=imread([pathname, filename]);
imshow(img,'Parent',handles.axes1);

Iniciar sesión para comentar.

Respuestas (2)

Andrew Reibold
Andrew Reibold el 11 de Mayo de 2013
Editada: Andrew Reibold el 11 de Mayo de 2013
Hi Sajid,
Do you mean you want to push the button, select an image from a folder, and then load the image to the screen?
If thats what you mean, this is what you do. ...
1) Add an axis into your GUI where you want the picture to show up.
-----This is done very easily in GUIDE, there is a button to create an axis on the left panel
2) Edit the push button callback to include the following
[File_Name, Path_Name] = uigetfile('PATHNAME')
axes('handles.myaxistag')
imshow([Path_Name,File_Name])
Above, PATHNAME is the location of the folder that your picture is located in.
...
AN EXAMPLE : )
...
If I have a situation where the location of my picture is 'D:\Users\Public\Pictures\Sample Pictures' and the TAG property of my axis is myaxistag, my code would look like this inside of the push button callback:
[File_Name, Path_Name] = uigetfile('D:\Users\Public\Pictures\Sample Pictures')
axes('handles.myaxistag')
imshow([Path_Name,File_Name])
If you do not know the location of your file, or if it might change, just leave it blank and it will be ok.
...
EXPLANATION IF YOU WANT TO KNOW WHAT IS HAPPENING
...
When you press the button the code will activate. The first line will open a window for you to select the picture you want to load. The PATHNAME just helps you find it faster.
The second line selects the axis. It tells the computer "This is what I want you to keep in mind right now"
The last line takes the file location from the first line, and tries to load it as an image where ever the "Computer is thinking of right now", in this case, the axes we selected.
Hopefully now your image is showing!
...
Disclaimer: I have not test run that code. Just off the top of my head.
Message or comment if it doesn't work, I will try to get back with you!
-Andrew Reibold
  3 comentarios
Image Analyst
Image Analyst el 18 de Mzo. de 2015
Both of you: show your code. How can we give advice if you don't show your code. If you were an expert, would you be able to answer a question like that with what was provided? Please read this: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
D LQ
D LQ el 17 de Mzo. de 2017
Hi :), if someone read that, the code shown by Andrew is correct, however, I changed the line
axes('handles.myaxistag')
with (i.e. without quotes):
axes(handles.myaxistag)
where "handles" is defined by the sign of function
function buttonToLoadImage_Callback(hObject, eventdata, handles)
Regards ñ_ñ

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 11 de Mayo de 2013
Description
This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. .........

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by