Load an image which i choose from a spesific folder

I'm building a GUI in which i have a button that i want to load an image from specific folder.But i don't want a specific image.I want to have the choise to choose one image that i want(not multiple images just one).Is there any way to push that button open me the folder and choose my image? Images files must be (.bmp) Thanks a lot

 채택된 답변

Bego
Bego 2016년 9월 16일
편집: Bego 2016년 9월 16일
Hello Thanos!
In your GUI add a EditText (Tag edit1) and a Push button (Tag pushbutton1). Right click over the push button and select View Callbacks/Callback. On the pushbutton1_Callback write something like this:
%Open dialog box and select and image from it
[filename,filepath]=uigetfile({'*.bmp'},'Select and image');
%Set the value of the text field edit1 to the route of the selected image.
set(handles.edit1, 'String', strcat(filepath, filename));
Regards,

댓글 수: 3

Thanks for the help!but i don't want the edit1!i want when this button take the image to be stored in anoher value something like this
figure; [filename,filepath]=uigetfile({'*.bmp'},'Select and image'); a=[filename,filepath]; imshow(a); i don't know if it is correct
Bego
Bego 2016년 9월 16일
편집: Bego 2016년 9월 16일
If you want to display the selected image on a Figure window then you should do something like:
[filename,filepath]=uigetfile({'*.bmp'},'Select and image');
selectedImage = imread(strcat(filepath, filename));
imshow(selectedImage);
Regards,
It worked!!!Thanks for the help again!UR the best!!!

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

추가 답변 (1개)

PRAJWAL GOWDA HM
PRAJWAL GOWDA HM 2019년 7월 13일

0 개 추천

[filename,filepath]=uigetfile({'*.bmp'},'Select and image');
selectedImage = imread(strcat(filepath, filename));
imshow(selectedImage);

질문:

2016년 9월 16일

답변:

2019년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by