selecting image from only one folder

1 view (last 30 days)
Iwan Manalu
Iwan Manalu on 24 Feb 2015
Edited: Joseph Cheng on 25 Feb 2015
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..

Answers (2)

Image Analyst
Image Analyst on 24 Feb 2015
Why would images from not in the DR folder show up on your GUI???
  1 Comment
Iwan Manalu
Iwan Manalu on 24 Feb 2015
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

Sign in to comment.


Joseph Cheng
Joseph Cheng on 24 Feb 2015
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 Comments
Iwan Manalu
Iwan Manalu on 24 Feb 2015
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 on 25 Feb 2015
Edited: Joseph Cheng on 25 Feb 2015
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.

Sign in to comment.

Categories

Find more on Display Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!