selecting image from only one folder

4 ビュー (過去 30 日間)
Iwan Manalu
Iwan Manalu 2015 年 2 月 24 日
編集済み: Joseph Cheng 2015 年 2 月 25 日
can anyone teach me source code for selecting image only from one folder, example i have images on directory D:\TA\DR\, in folder DR i have 25 images, i have made a GUI, i want if i choose images from directry DR will be show on GUI, and if i choose images from non directory DR will be not shown on gui
thanks for helping me..

回答 (2 件)

Image Analyst
Image Analyst 2015 年 2 月 24 日
Why would images from not in the DR folder show up on your GUI???
  1 件のコメント
Iwan Manalu
Iwan Manalu 2015 年 2 月 24 日
because my lecturer need only images from DR folder that would be show and process sir, if image came from not DR folder it will not be show n process on GUI

サインインしてコメントする。


Joseph Cheng
Joseph Cheng 2015 年 2 月 24 日
so i'm assuming you're using something like this [file folder]=uigetfile('D:\TA\DR\');
you can put after that to string compare the result with your specific directory
if ~strcmp(folder,'D:\TA\DR\')
%error message or just don't do anything
else
%whatever you plan to do such as load image display the file in GUI, etc.
end
  2 件のコメント
Iwan Manalu
Iwan Manalu 2015 年 2 月 24 日
my coding on gui like this sir
proyek=guidata(gcbo);
[nama_file,nama_path] = uigetfile({'*.jpg';'*.bmp';'*.png';'*.tif'},'Buka Citra');
if ~isequal(nama_file,0);
handles.data1 = imread(fullfile(nama_path,nama_file));
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.data1);
title('Citra Asli');
else
return
end
this coding show images from any folder, i just want show image from folder that i want
Joseph Cheng
Joseph Cheng 2015 年 2 月 25 日
編集済み: Joseph Cheng 2015 年 2 月 25 日
so..... i don't see where the issue is. like i described in my example you are using uigetdir compare the folder (in your example nama_path) to the specified actual path. basically it is already there and add the additional check to the if statement to the if statement
if ~isequal(nama_file,0)&isequal(nama_file,whateverfolderyouwanted);
Are you asking for them not to be able to navigate away from the specified path? because then the method that i described only would not let them load files outside the zone. If you only want specific files from a specific place you're better off building a separate gui that you pop up with a listbox that you can populate with all the files listed with those extensions. I wouldn't hard code the file names in but you can get all the file names with the dir function and use a loop to populate the files they can select from.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by