function varargout = GUI_2(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_2_OpeningFcn, ...
'gui_OutputFcn', @GUI_2_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function GUI_2_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = GUI_2_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function listbox1_Callback(hObject, eventdata, handles)
function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton1_Callback(hObject, eventdata, handles)
folder_name = uigetdir;
Infolder = dir(folder_name);
MyListOfFiles = {Infolder(~[Infolder.isdir]).name};
set(handles.listbox1,'String', MyListOfFiles);
handles.inDir = folder_name;
guidata(hObject,handles);
function pushbutton2_Callback(hObject, eventdata, handles)
[file,path]=uiputfile('*.jpg','Save Destination');
function pushbutton3_Callback(hObject, eventdata, handles)
if(nargin<2)
outDir = 'H:\Documents\DIP\Batch_processed_HSV';
end
if(nargin<1)
inDir = 'MyListOfFiles';
end
includeSubdirectories = true;
imreadFormats = imformats;
supportedExtensions = [imreadFormats.ext];
supportedExtensions{end+1} = 'dcm';
supportedExtensions{end+1} = 'ima';
supportedExtensions = strcat('.',supportedExtensions);
supportedExtensions{end+1} = '';
imds = datastore(inDir,...
'IncludeSubfolders', includeSubdirectories,...
'Type','image',...
'FileExtensions',supportedExtensions);
imds.ReadFcn = @readSupportedImage;
for imgInd = 1:numel(imds.Files)
inImageFile = imds.Files{imgInd};
outImageFile = strrep(inImageFile, inDir, outDir);
try
im = imds.readimage(imgInd);
im = trial_3(im);
outSubDir = fileparts(outImageFile);
createDirectory(outSubDir);
if(isdicom(inImageFile))
dicommeta = dicominfo(inImageFile);
dicomwrite(im, outImageFile, dicommeta, 'CreateMode', 'copy');
else
imwrite(im, outImageFile);
end
disp(['PASSED:', inImageFile]);
catch allExceptions
disp(['FAILED:', inImageFile]);
disp(getReport(allExceptions,'basic'));
end
end
myFolder='H:\Documents\DIP\Batch_Processed_HSV';
filePattern=fullfile(myFolder, '*.JPG');
theFiles=dir(filePattern);
Interval=input('Enter the time interval for the camera (Seconds):')
for k=1:length(theFiles)
baseFileName=theFiles(k).name;
fullFileName=fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
image=imread(fullFileName);
white=nnz(image);
black=(numel(image)-white);
if black>(numel(image)*0.0193);
disp('The experiment is complete at this stage!')
fprintf('The number of Black Pixels is:');
disp(numel(image)-white);
disp('Time of Picture (Secs): ');
disp((k-1)*Interval);
else
disp('The experiment is not complete yet.')
fprintf('The number of Black Pixels is:');
disp(numel(image)-white);
end
end
function pushbutton4_Callback(hObject, eventdata, handles)
msgbox('Thankyou for using the Image Processing Tool');
pause(3);
close();
close();
function listbox2_Callback(hObject, eventdata, handles)
function listbox2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end