Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function varargout = gui_replica(varargin)
- % gui_replica MATLAB code for gui_replica.fig
- % gui_replica, by itself, creates a new gui_replica or raises the existing
- % singleton*.
- %
- % H = gui_replica returns the handle to a new gui_replica or the handle to
- % the existing singleton*.
- %
- % gui_replica('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in gui_replica.M with the given input arguments.
- %
- % gui_replica('Property','Value',...) creates a new gui_replica or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before gui_replica_OpeningFcn gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to gui_replica_OpeningFcn via varargin.
- %
- % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
- % instance to run (singleton)".
- %
- % See also: GUIDE, GUIDATA, GUIHANDLES
- % Edit the above text to modify the response to help gui_replica
- % Last Modified by GUIDE v2.5 21-Dec-2017 10:11:26
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @gui_replica_OpeningFcn, ...
- 'gui_OutputFcn', @gui_replica_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
- % End initialization code - DO NOT EDIT
- % --- Executes just before gui_replica is made visible.
- function gui_replica_OpeningFcn(hObject, eventdata, handles, varargin)
- % This function has no output args, see OutputFcn.
- % hObject handle to figure
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % varargin command line arguments to gui_replica (see VARARGIN)
- img = imread('logo-tbl.png');
- axes(handles.axes4)
- imshow(img)
- axis off
- axis image
- % Choose default command line output for gui_replica
- handles.output = hObject;
- % Update handles structure
- guidata(hObject, handles);
- % UIWAIT makes gui_replica wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- % --- Outputs from this function are returned to the command line.
- function varargout = gui_replica_OutputFcn(hObject, eventdata, handles)
- % varargout cell array for returning output args (see VARARGOUT);
- % hObject handle to figure
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Get default command line output from handles structure
- varargout{1} = handles.output;
- % --- Executes on button press in pushbutton1.
- function pushbutton1_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % [file_name,path_name] = uigetfile('*.jpg','Select image file');
- % full_path = [path_name,'\',file_name];
- % handles.filename=full_path;
- % guidata(hObject,handles)
- % img = imread(full_path);
- % axes(handles.axes1)
- % imshow(img)
- % axis off
- % axis image
- % --- Executes on button press in pushbutton2.
- function pushbutton2_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- OpenfilePath = uigetdir;
- % OpenfilePath = 'C:\Users\TBL\Documents\MATLAB\Yujin_Data\20170404_Amore_Replica\Eye-rim\5-Y';
- max_step = 994;
- avg_rough = zeros(1,max_step);
- rms_rough = zeros(1,max_step);
- max_rough = zeros(1,max_step);
- total_rough = zeros(1,max_step);
- % full_path = handles.filename;
- diff = 2;
- l_crop = 156;
- r_crop = 10;
- t_crop = 45;
- b_crop = 5;
- for step = 1:max_step
- offset = 6;
- num = sprintf('%d',step+offset);
- file_name = strcat('bb _',num,'.jpg');
- img0 = imread([OpenfilePath,'\',file_name]);
- img = rgb2gray(img0);
- [H,W] = size(img);
- img = flip(img, 1);
- [img_crop,H_crop,W_crop] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
- img_filt = imgaussfilt(img_crop,6);
- img_diff = filt_diff(img_filt,H_crop,W_crop,diff);
- %ref_line to ref+line_surf
- [img_line_surf,ind_line_surf,avg_index,ref_line_surf] = line_surf2(img_diff,H_crop,W_crop,diff);
- img3d(:,:,step) = img_line_surf;
- [peak_height_front,valley_depth_front] = peak_valley(ind_line_surf,avg_index,W_crop);
- [avg_rough_front(step),rms_rough_front(step),max_rough_front(step),total_rough_front(step)] = roughness(peak_height_front,valley_depth_front);
- fprintf('%d\n', step);
- end
- avg_roughness = zeros(1,W_crop);
- rms_roughness = zeros(1,W_crop);
- max_roughness = zeros(1,W_crop);
- total_roughness = zeros(1,W_crop);
- for ii = 1:W_crop
- s = img3d(:,ii,:);
- s = squeeze(s);
- [Hs,Ws] = size(s);
- [row,col] = find(s);
- avg_index_side = round(mean(row));
- ref_line = zeros(Hs,Ws);
- ref_line(avg_index_side,:) = 255;
- abs_roughness = zeros(1,Ws);
- [peak_height_side,valley_depth_side] = peak_valley(row,avg_index_side,W_crop);
- [avg_rough_side(ii),rms_rough_side(ii),max_rough_side(ii),total_rough_side(ii)] = roughness(peak_height_side,valley_depth_side);
- fprintf('%d\n', ii);
- end
- %mean_avg_rough_front = mean(avg_rough_front)
- % mean_rms_rough_front = mean(rms_rough_front)
- % mean_max_rough_front = mean(max_rough_front)
- % mean_total_rough_front = mean(total_rough_front)
- disp('Front view roughness');
- text_avg_rough_front = sprintf('%.2f', mean(avg_rough_front));
- text_rms_rough_front = sprintf('%.2f', mean(rms_rough_front));
- text_max_rough_front = sprintf('%.2f', mean(max_rough_front));
- text_total_rough_front = sprintf('%.2f', mean(total_rough_front));
- set(handles.text13, 'String', text_avg_rough_front);
- set(handles.text14, 'String', text_rms_rough_front);
- set(handles.text15, 'String', text_max_rough_front);
- set(handles.text16, 'String', text_total_rough_front);
- disp('Side view roughness');
- text_avg_rough = sprintf('%.2f', mean(avg_rough_side));
- text_rms_rough = sprintf('%.2f', mean(rms_rough_side));
- text_max_rough = sprintf('%.2f', mean(max_rough_side));
- text_total_rough = sprintf('%.2f', mean(total_rough_side));
- set(handles.text25, 'String', text_avg_rough);
- set(handles.text26, 'String', text_rms_rough);
- set(handles.text29, 'String', text_max_rough);
- set(handles.text30, 'String', text_total_rough);
- axes(handles.axes1)
- %imshow(img)
- axis off
- axis image
- imshow(img0);
- r1 = img_crop;
- g1 = r1;
- b1 = r1;
- r1(img_line_surf > 0) = 255;
- g1(img_line_surf > 0) = 0; %%
- b1(ref_line_surf > 0) = 255; %
- axes(handles.axes3)
- %imshow(img)
- axis off
- axis image
- imshow(cat(3,r1,g1,b1),[]);
- % figure('Name','Wrinkle')
- % imshow();
- % imshow(img_crop,[], 'parent',handle.axes1)
- % imshow(cat(3,r1,g1,b1),[], 'parent',handle.axes3)
- % %% Roughness Values
- % text_avg_rough = sprintf('%.2f', avg_rough);
- % text_rms_rough = sprintf('%.2f', rms_rough);
- % text_max_rough = sprintf('%.2f', max_rough);
- % text_total_rough = sprintf('%.2f', total_rough);
- %
- % set(handles.text13, 'String', text_avg_rough);
- % set(handles.text14, 'String', text_rms_rough);
- % set(handles.text15, 'String', text_max_rough);
- % set(handles.text16, 'String', text_total_rough);
- % img = imread(full_path);
- % [H,W] = size(img);
- % %% Parameters setup
- % l_crop = 18;
- % r_crop = 18;
- % t_crop = 12;
- % b_crop = 10;
- % diff = 2;
- % med = 80;
- % wind_size = 40;
- % threshold = 30;
- % %% Preprocessing
- % [img_crop,H_crop,W_crop] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
- % img_filt = imgaussfilt(img_crop,7);
- % %% Wrinkle surface
- % img_diff = filt_diff(img_filt,H_crop,W_crop,diff);
- % [img_line_wrinkle,ind_line_wrinkle,avg_index,ref_line] = line_surf1(img_diff,H_crop,W_crop,diff);
- %
- % [peak_height,valley_depth] = peak_valley(ind_line_wrinkle,avg_index,W_crop);
- % [avg_rough,rms_rough,max_rough,total_rough] = roughness(peak_height,valley_depth);
- %
- % %% Roughness Values
- % text_avg_rough = sprintf('%.2f', avg_rough);
- % text_rms_rough = sprintf('%.2f', rms_rough);
- % text_max_rough = sprintf('%.2f', max_rough);
- % text_total_rough = sprintf('%.2f', total_rough);
- %
- % set(handles.text13, 'String', text_avg_rough);
- % set(handles.text14, 'String', text_rms_rough);
- % set(handles.text15, 'String', text_max_rough);
- % set(handles.text16, 'String', text_total_rough);
- % --- Executes on button press in pushbutton3.
- function pushbutton3_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --- Executes on button press in pushbutton4.
- function pushbutton4_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --- Executes on button press in pushbutton5.
- function pushbutton5_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --- Executes on button press in pushbutton6.
- function pushbutton6_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --- Executes on button press in pushbutton7.
- function pushbutton7_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --- Executes during object creation, after setting all properties.
- function text21_CreateFcn(hObject, eventdata, handles)
- % hObject handle to text21 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % --- Executes during object creation, after setting all properties.
- function axes1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to axes1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: place code in OpeningFcn to populate axes1
- % --- Executes during object deletion, before destroying properties.
- function axes1_DeleteFcn(hObject, eventdata, handles)
- % hObject handle to axes1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --- Executes on mouse press over axes background.
- function axes1_ButtonDownFcn(hObject, eventdata, handles)
- % hObject handle to axes1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
Advertisement
Add Comment
Please, Sign In to add comment