GUI Pushbutton, display user input?
Mostrar comentarios más antiguos
Hi, I wrote the following code to pull out a user defined increment of photos and file those photos somewhere else (user defined) for DIC. For the pushbutton with the uigetdir prompt, I would like it to orginally say "Directory" or something, then once the user pushes the button the user navigates to their desired directory, then I would like the pushbutton to display what directory the user chose. How do I do this?
%In order to work the image files of interest must be in the current
%path/directory. They also must be in the .jpg format.
clear all;
clc;
f= figure;
selpath = 'Directory';
uicontrol(f,'style', 'text','string', 'Enter Index','position', [65,355,100,20]);
cinput = uicontrol(f,'style', 'edit','String','#','position', [100,325,30,30],'callback','c = get(cinput);C=c.String;I=str2num(C);');
uicontrol(f,'style', 'text','string', 'Enter New Folder Name','position', [300,355,120,20]);
binput = uicontrol(f,'style', 'edit','string', 'NewFolderName','position', [260,325,200,30],'callback','b = get(binput);B=b.String;');
bdinput = uicontrol(f,'style', 'pushbutton','string', selpath,'position', [100,255,360,30], 'callback', 'selpath = uigetdir;');
uicontrol(f,'style', 'pushbutton','string', 'Done','position', [460,200,40,30], 'callback', 'closereq');
uiwait(f);
imagefiles = dir('*.jpg');%Find the jpg files
nfiles = length(imagefiles);%How many files are there
if nfiles ==0 %If there are no .jpg files found output a message
message1= sprintf('Please add your image folder to the current directory navigation bar.');
msgbox(message1);
end
for ii=1:nfiles
currentfilename = imagefiles(ii).name;
currentimage = imread(currentfilename);
images{ii} = currentimage;
end
for jj = 1:I:nfiles
bestdirectory = strcat(selpath,'\',B);%choosen by user
mkdir(bestdirectory);
j=['Image_S001_' num2str(jj-1,'%04d') '.jpg'];
fulldestination = fullfile(bestdirectory,j); %name file relative to that directory
q=images{jj};
imwrite(q, fulldestination); %save the file there directory
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Environment and Settings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!