I'm still new with GUI. I want to create a folder In GUI, each time I push a button. I will also set some images in this folder.
I will actually call a funktion that crop some images. The problem is, when I create a new folder in GUI by pushing a button, the folder is empty and the function therefore does nothing.
I make a funktion for create a folder as below:
function handles = directory( handles )
direct = uigetdir(pwd, 'Select Directory');
handles.myData.direct = direct;
end
a funktion that crop images is:
function handles = Cropbillede( handles )
folder_name = uigetdir;
ImagesToRead = dir(fullfile(folder_name, '*tif'));
ImageCell=cell(length(ImagesToRead),1);
CroppedImageCell=cell(length(ImagesToRead),1);
for k = 1 : length(ImagesToRead)
ImageCell{k} = imread(ImagesToRead(k).name); % Read image and store in cell array.
CroppedImageCell{k} = imcrop(ImageCell{k},[0 0 1045 791]); % See comments below
end
SequenceName = 'CroppedBone' ;
for k = 1:length(ImagesToRead)
ExportedName = sprintf('%s%03d.tif',SequenceName,k); % Add the frame # after the name
imwrite(CroppedImageCell{k}... ,ExportedName,... 'tif','WriteMode','overwrite','Compression','none');
end
for k = 1:length(ImagesToRead)
imwrite(CroppedImageCell{k},handles.myData.direct,SequenceName,... 'tif','WriteMode','append','Compression','none'); % Note the "append" writing mode.
end
end
and in my GUI:
function textfield_Callback(hObject, eventdata, handles)
handles = directory( handles ); guidata(hObject,handles); handles = Cropbillede( handles ); guidata(hObject,handles);
Anyone knows what is the problem in this code? and how to put images in this folder?
thanks in advance.
Best Answer