tuttelikz

gui_replica.m [v1latest]

Dec 27th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 34.30 KB | None | 0 0
  1. function varargout = gui_replica(varargin)
  2. % gui_replica MATLAB code for gui_replica.fig
  3. %      gui_replica, by itself, creates a new gui_replica or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = gui_replica returns the handle to a new gui_replica or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      gui_replica('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in gui_replica.M with the given input arguments.
  11. %
  12. %      gui_replica('Property','Value',...) creates a new gui_replica or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before gui_replica_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to gui_replica_OpeningFcn via varargin.
  17. %
  18. %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  19. %      instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22.  
  23. % Edit the above text to modify the response to help gui_replica
  24.  
  25. % Last Modified by GUIDE v2.5 27-Dec-2017 16:45:15
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name',       mfilename, ...
  30.                    'gui_Singleton',  gui_Singleton, ...
  31.                    'gui_OpeningFcn', @gui_replica_OpeningFcn, ...
  32.                    'gui_OutputFcn',  @gui_replica_OutputFcn, ...
  33.                    'gui_LayoutFcn',  [] , ...
  34.                    'gui_Callback',   []);
  35. if nargin && ischar(varargin{1})
  36.     gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42.     gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before gui_replica is made visible.
  48. function gui_replica_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject    handle to figure
  51. % eventdata  reserved - to be defined in a future version of MATLAB
  52. % handles    structure with handles and user data (see GUIDATA)
  53. % varargin   command line arguments to gui_replica (see VARARGIN)
  54.  
  55.  
  56.  
  57.  
  58. % img = imread('logo-tbl.png');
  59. % axes(handles.axes4)
  60. % imshow(img)
  61. % axis off
  62. % axis image
  63.  
  64. % Choose default command line output for gui_replica
  65. handles.output = hObject;
  66.  
  67. % Update handles structure
  68. guidata(hObject, handles);
  69.  
  70. % UIWAIT makes gui_replica wait for user response (see UIRESUME)
  71. % uiwait(handles.figure1);
  72.  
  73.  
  74. % --- Outputs from this function are returned to the command line.
  75. function varargout = gui_replica_OutputFcn(hObject, eventdata, handles)
  76. % varargout  cell array for returning output args (see VARARGOUT);
  77. % hObject    handle to figure
  78. % eventdata  reserved - to be defined in a future version of MATLAB
  79. % handles    structure with handles and user data (see GUIDATA)
  80.  
  81. % Get default command line output from handles structure
  82. varargout{1} = handles.output;
  83.  
  84.  
  85. % --- Executes on button press in pushbutton1.
  86. function pushbutton1_Callback(hObject, eventdata, handles)
  87. % hObject    handle to pushbutton1 (see GCBO)
  88. % eventdata  reserved - to be defined in a future version of MATLAB
  89. % handles    structure with handles and user data (see GUIDATA)
  90.  
  91.  
  92.  
  93.  
  94. % [file_name,path_name] = uigetfile('*.jpg','Select image file');
  95. % full_path = [path_name,'\',file_name];
  96. % handles.filename=full_path;
  97. % guidata(hObject,handles)
  98. % img = imread(full_path);
  99. % axes(handles.axes1)
  100. % imshow(img)
  101. % axis off
  102. % axis image
  103.  
  104.  
  105.  
  106.  
  107.  
  108. % --- Executes on button press in pushbutton2.
  109. function pushbutton2_Callback(hObject, eventdata, handles)
  110. % hObject    handle to pushbutton2 (see GCBO)
  111. % eventdata  reserved - to be defined in a future version of MATLAB
  112. % handles    structure with handles and user data (see GUIDATA)
  113. filePath = uigetdir;
  114. imgFilePath = dir([filePath '/*.jpg']);
  115. imgFilesNo = size(imgFilePath,1);
  116. imgName = imgFilePath(1).name;
  117.  
  118. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  119. handles.filePath = filePath;
  120. handles.imgFolderInfo = imgFilePath;
  121. handles.imgName = imgName;
  122. handles.imgOrder = 1;
  123. handles.imgTotal = imgFilesNo;
  124. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  125. handles.lcrop = 0;
  126. handles.rcrop = 0;
  127. handles.tcrop = 0;
  128. handles.bcrop = 0;
  129. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  130. handles.g1Val = 2;
  131. handles.g2Val = 4;
  132. handles.medVal = 20;
  133. handles.diff = 2;
  134. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  135. guidata(hObject,handles);
  136.  
  137. set(handles.imgOrderLabel, 'String', handles.imgOrder);
  138. set(handles.imgTotalLabel, 'String', imgFilesNo);
  139.  
  140. img = imread([filePath,'\',imgName]);
  141. axes(handles.axes1)
  142. %imshow(img)
  143. axis off
  144. axis image
  145. imshow(img);
  146.  
  147. % imgName = imgFilePath(1).name;
  148. [H,W] = size(img);
  149. img3d = zeros(H,W,imgFilesNo);
  150. handles.imgHeight = H;
  151. handles.imgWidth = W;
  152. guidata(hObject,handles);
  153.  
  154. for step = 1:imgFilesNo
  155.     file_name = imgFilePath(step).name;
  156. %     [H,W] = size(img);
  157.     img = imread([filePath,'\',file_name]);
  158.     img3d(:,:,step) = img;
  159.     fprintf('%d\n', step);
  160. end
  161.  
  162. avg = mean(img3d,1);
  163. avg = squeeze(avg);
  164. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  165. axes(handles.axes3)
  166. axis image
  167. imshow(avg,[]);
  168. hold on
  169.  
  170. x = [1 W];
  171. y = [handles.imgOrder handles.imgOrder];
  172. handles.lineRef  = line(x,y,'Color','red','LineStyle','--','LineWidth',2);
  173.  
  174. guidata(hObject,handles);
  175.  
  176. hold off
  177.  
  178. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  179. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  180.    
  181. img_gau = imgaussfilt(img_crp,handles.g1Val);
  182. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  183. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  184.  
  185. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  186. img_med = filt_diff(img_med,H,W,handles.diff);
  187.  
  188. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  189. mrg = 60;
  190. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  191.  
  192. img_gau = imgaussfilt(img_flt,handles.g2Val);
  193. img_diff = filt_diff(img_gau,H,W,handles.diff);
  194.  
  195. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  196. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  197. axes(handles.imgOutputAxes)
  198. axis image
  199. imshow(img_rl,[]);
  200. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  201.  
  202.  
  203. % [H,W,I] = size(img3d);
  204.  
  205. % avg = zeros(W,imgFilesNo);
  206. % for i = 1:W
  207. %     for j = 1:imgFilesNo
  208. %         avg(i,j) = sum(double(img3d(:,i,j)))/imgFilesNo;
  209. %     end
  210. % end
  211.  
  212.  
  213.  
  214. %     fprintf('%d\n', step);
  215.  
  216. % OpenfilePath = 'C:\Users\TBL\Documents\MATLAB\Yujin_Data\20170404_Amore_Replica\Eye-rim\5-Y';
  217.  
  218. % max_step = 994;
  219. % avg_rough = zeros(1,max_step);
  220. % rms_rough = zeros(1,max_step);
  221. % max_rough = zeros(1,max_step);
  222. % total_rough = zeros(1,max_step);
  223. %
  224. % % full_path = handles.filename;
  225. % diff = 2;
  226. % l_crop = 156;
  227. % r_crop = 10;
  228. % t_crop = 45;
  229. % b_crop = 5;
  230.  
  231. % for step = 1:max_step
  232. %     offset = 6;
  233. %     num = sprintf('%d',step+offset);
  234. %     file_name = strcat('bb _',num,'.jpg');
  235. %     img0 = imread([OpenfilePath,'\',file_name]);
  236. %     img = rgb2gray(img0);
  237. %     [H,W] = size(img);
  238. %     img = flip(img, 1);
  239. %     [img_crop,H_crop,W_crop] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
  240. %     img_filt = imgaussfilt(img_crop,6);
  241. %     img_diff = filt_diff(img_filt,H_crop,W_crop,diff);
  242. %    
  243. %     %ref_line to ref+line_surf
  244. %     [img_line_surf,ind_line_surf,avg_index,ref_line_surf] = line_surf2(img_diff,H_crop,W_crop,diff);
  245. %     img3d(:,:,step) = img_line_surf;
  246. %
  247. %     [peak_height_front,valley_depth_front] = peak_valley(ind_line_surf,avg_index,W_crop);
  248. %     [avg_rough_front(step),rms_rough_front(step),max_rough_front(step),total_rough_front(step)] = roughness(peak_height_front,valley_depth_front);
  249. %
  250. %     fprintf('%d\n', step);
  251. %
  252. % end
  253.  
  254. % avg_roughness = zeros(1,W_crop);
  255. % rms_roughness = zeros(1,W_crop);
  256. % max_roughness = zeros(1,W_crop);
  257. % total_roughness = zeros(1,W_crop);
  258.  
  259. % for ii = 1:W_crop
  260. %     s = img3d(:,ii,:);
  261. %     s = squeeze(s);
  262. %     [Hs,Ws] = size(s);
  263. %     [row,col] = find(s);
  264. %
  265. %     avg_index_side = round(mean(row));
  266. %     ref_line = zeros(Hs,Ws);
  267. %     ref_line(avg_index_side,:) = 255;
  268. %
  269. %     abs_roughness = zeros(1,Ws);
  270. %    
  271. %     [peak_height_side,valley_depth_side] = peak_valley(row,avg_index_side,W_crop);
  272. %     [avg_rough_side(ii),rms_rough_side(ii),max_rough_side(ii),total_rough_side(ii)] = roughness(peak_height_side,valley_depth_side);
  273. %    
  274. %     fprintf('%d\n', ii);
  275. %  
  276. % end
  277.  
  278.  
  279.  
  280. %mean_avg_rough_front = mean(avg_rough_front)
  281. % mean_rms_rough_front = mean(rms_rough_front)
  282. % mean_max_rough_front = mean(max_rough_front)
  283. % mean_total_rough_front = mean(total_rough_front)
  284. % disp('Front view roughness');
  285. %
  286. % text_avg_rough_front = sprintf('%.2f', mean(avg_rough_front));
  287. % text_rms_rough_front = sprintf('%.2f', mean(rms_rough_front));
  288. % text_max_rough_front = sprintf('%.2f', mean(max_rough_front));
  289. % text_total_rough_front = sprintf('%.2f', mean(total_rough_front));
  290. %
  291. % set(handles.text13, 'String', text_avg_rough_front);
  292. % set(handles.text14, 'String', text_rms_rough_front);
  293. % set(handles.text15, 'String', text_max_rough_front);
  294. % set(handles.text16, 'String', text_total_rough_front);
  295. %
  296. %
  297. % disp('Side view roughness');
  298.  
  299. % text_avg_rough = sprintf('%.2f', mean(avg_rough_side));
  300. % text_rms_rough = sprintf('%.2f', mean(rms_rough_side));
  301. % text_max_rough = sprintf('%.2f', mean(max_rough_side));
  302. % text_total_rough = sprintf('%.2f', mean(total_rough_side));
  303. %
  304. % set(handles.text25, 'String', text_avg_rough);
  305. % set(handles.text26, 'String', text_rms_rough);
  306. % set(handles.text29, 'String', text_max_rough);
  307. % set(handles.text30, 'String', text_total_rough);
  308. %
  309. %
  310. %
  311. %
  312. % axes(handles.axes1)
  313. % %imshow(img)
  314. % axis off
  315. % axis image
  316. % imshow(img0);
  317. %
  318. %
  319. % r1 = img_crop;
  320. % g1 = r1;
  321. % b1 = r1;
  322. % r1(img_line_surf > 0) = 255;
  323. % g1(img_line_surf > 0) = 0; %%
  324. % b1(ref_line_surf > 0) = 255; %
  325. %
  326. % axes(handles.axes3)
  327. % %imshow(img)
  328. % axis off
  329. % axis image
  330. % imshow(cat(3,r1,g1,b1),[]);
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337. % figure('Name','Wrinkle')
  338. % imshow();
  339.  
  340. % imshow(img_crop,[], 'parent',handle.axes1)
  341. % imshow(cat(3,r1,g1,b1),[], 'parent',handle.axes3)
  342.  
  343. % %% Roughness Values
  344. % text_avg_rough = sprintf('%.2f', avg_rough);
  345. % text_rms_rough = sprintf('%.2f', rms_rough);
  346. % text_max_rough = sprintf('%.2f', max_rough);
  347. % text_total_rough = sprintf('%.2f', total_rough);
  348. %
  349. % set(handles.text13, 'String', text_avg_rough);
  350. % set(handles.text14, 'String', text_rms_rough);
  351. % set(handles.text15, 'String', text_max_rough);
  352. % set(handles.text16, 'String', text_total_rough);
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359. % img = imread(full_path);
  360. % [H,W] = size(img);
  361. % %% Parameters setup
  362. % l_crop = 18;
  363. % r_crop = 18;
  364. % t_crop = 12;
  365. % b_crop = 10;
  366. % diff = 2;
  367. % med = 80;
  368. % wind_size = 40;
  369. % threshold = 30;
  370. % %% Preprocessing
  371. % [img_crop,H_crop,W_crop] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
  372. % img_filt = imgaussfilt(img_crop,7);
  373. % %% Wrinkle surface
  374. % img_diff = filt_diff(img_filt,H_crop,W_crop,diff);
  375. % [img_line_wrinkle,ind_line_wrinkle,avg_index,ref_line] = line_surf1(img_diff,H_crop,W_crop,diff);
  376. %
  377. % [peak_height,valley_depth] = peak_valley(ind_line_wrinkle,avg_index,W_crop);
  378. % [avg_rough,rms_rough,max_rough,total_rough] = roughness(peak_height,valley_depth);
  379. %
  380. % %% Roughness Values
  381. % text_avg_rough = sprintf('%.2f', avg_rough);
  382. % text_rms_rough = sprintf('%.2f', rms_rough);
  383. % text_max_rough = sprintf('%.2f', max_rough);
  384. % text_total_rough = sprintf('%.2f', total_rough);
  385. %
  386. % set(handles.text13, 'String', text_avg_rough);
  387. % set(handles.text14, 'String', text_rms_rough);
  388. % set(handles.text15, 'String', text_max_rough);
  389. % set(handles.text16, 'String', text_total_rough);
  390.  
  391.  
  392.  
  393. % --- Executes on button press in pushbutton3.
  394. function pushbutton3_Callback(hObject, eventdata, handles)
  395. % hObject    handle to pushbutton3 (see GCBO)
  396. % eventdata  reserved - to be defined in a future version of MATLAB
  397. % handles    structure with handles and user data (see GUIDATA)
  398.  
  399.  
  400. % --- Executes on button press in pushbutton4.
  401. function pushbutton4_Callback(hObject, eventdata, handles)
  402. % hObject    handle to pushbutton4 (see GCBO)
  403. % eventdata  reserved - to be defined in a future version of MATLAB
  404. % handles    structure with handles and user data (see GUIDATA)
  405.  
  406.  
  407.  
  408. % --- Executes on button press in pushbutton5.
  409. function pushbutton5_Callback(hObject, eventdata, handles)
  410. % hObject    handle to pushbutton5 (see GCBO)
  411. % eventdata  reserved - to be defined in a future version of MATLAB
  412. % handles    structure with handles and user data (see GUIDATA)
  413.  
  414.  
  415. % --- Executes on button press in pushbutton6.
  416. function pushbutton6_Callback(hObject, eventdata, handles)
  417. % hObject    handle to pushbutton6 (see GCBO)
  418. % eventdata  reserved - to be defined in a future version of MATLAB
  419. % handles    structure with handles and user data (see GUIDATA)
  420.  
  421.  
  422. % --- Executes on button press in pushbutton7.
  423. function pushbutton7_Callback(hObject, eventdata, handles)
  424. % hObject    handle to pushbutton7 (see GCBO)
  425. % eventdata  reserved - to be defined in a future version of MATLAB
  426. % handles    structure with handles and user data (see GUIDATA)
  427.  
  428.  
  429. % --- Executes during object creation, after setting all properties.
  430. function text21_CreateFcn(hObject, eventdata, handles)
  431. % hObject    handle to text21 (see GCBO)
  432. % eventdata  reserved - to be defined in a future version of MATLAB
  433. % handles    empty - handles not created until after all CreateFcns called
  434.  
  435.  
  436. % --- Executes on button press in btnNext.
  437. function btnNext_Callback(hObject, eventdata, handles)
  438. % hObject    handle to btnNext (see GCBO)
  439. % eventdata  reserved - to be defined in a future version of MATLAB
  440. % handles    structure with handles and user data (see GUIDATA)
  441. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  442.  
  443. if handles.imgOrder < handles.imgTotal
  444.     handles.imgOrder = handles.imgOrder + 1;
  445.     guidata(hObject,handles);
  446.     set(handles.imgOrderLabel, 'String', handles.imgOrder);
  447.    
  448.    
  449.     filePath = handles.filePath;
  450.     imgFilePath = handles.imgFolderInfo;
  451.     imgName = imgFilePath(handles.imgOrder).name;
  452.    
  453.     img = imread([filePath,'\',imgName]);
  454.     axes(handles.axes1)
  455.     axis off
  456.     axis image
  457.     imshow(img);
  458.    
  459.    
  460.    
  461.    
  462.    
  463.     delete(handles.lineRef);
  464.    
  465.     axes(handles.axes3)
  466. %     axis image
  467. %     imshow(avg,[]);
  468. %     hold on
  469.  
  470.     x = [1 handles.imgWidth];
  471.     y = [handles.imgOrder handles.imgOrder];
  472.    
  473.    
  474.     %handles.lineRef = c1;
  475.    
  476.    
  477.     handles.lineRef = line(x,y,'Color','red','LineStyle','--','LineWidth',2);
  478.    
  479.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  480.     handles.lcrop = 0;
  481.     handles.rcrop = 0;
  482.     handles.tcrop = 0;
  483.     handles.bcrop = 0;
  484.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  485.     handles.g1Val = 2;
  486.     handles.g2Val = 4;
  487.     handles.medVal = 20;
  488.     handles.diff = 2;
  489.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  490.  
  491.     guidata(hObject,handles);
  492.    
  493. %     hold off
  494.  
  495.     [H,W] = size(img);
  496.  
  497.     [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  498.    
  499.     img_gau = imgaussfilt(img_crp,handles.g1Val);
  500.     img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  501.     [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  502.  
  503.     img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  504.     img_med = filt_diff(img_med,H,W,handles.diff);
  505.  
  506.     [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  507.     mrg = 60;
  508.     [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  509.  
  510.     img_gau = imgaussfilt(img_flt,handles.g2Val);
  511.     img_diff = filt_diff(img_gau,H,W,handles.diff);
  512.  
  513.     [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  514.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  515.     axes(handles.imgOutputAxes)
  516.     axis image
  517.     imshow(img_rl,[]);
  518.    
  519.    
  520. end
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540. % save the changes to the structure
  541.  
  542.  
  543.  
  544. % handles.imgOrder = 1;
  545. % handles.imgTotal = folderImgNo;
  546. % guidata(hObject,handles);
  547.  
  548.  
  549. % set(handles.imgTotalLabel, 'String', folderImgNo);
  550.  
  551.  
  552.  
  553.  
  554. % --- Executes on button press in btnPrev.
  555. function btnPrev_Callback(hObject, eventdata, handles)
  556. % hObject    handle to btnPrev (see GCBO)
  557. % eventdata  reserved - to be defined in a future version of MATLAB
  558. % handles    structure with handles and user data (see GUIDATA)
  559. if handles.imgOrder > 1
  560.     handles.imgOrder = handles.imgOrder - 1;
  561.     guidata(hObject,handles);
  562.     set(handles.imgOrderLabel, 'String', handles.imgOrder);
  563.    
  564.    
  565.     filePath = handles.filePath;
  566.     imgFilePath = handles.imgFolderInfo;
  567.     imgName = imgFilePath(handles.imgOrder).name;
  568.    
  569.     img = imread([filePath,'\',imgName]);
  570.     axes(handles.axes1)
  571.     axis off
  572.     axis image
  573.     imshow(img);
  574.    
  575.    
  576.    
  577.     delete(handles.lineRef);
  578.     axes(handles.axes3)
  579.  
  580.     x = [1 handles.imgWidth];
  581.     y = [handles.imgOrder handles.imgOrder];
  582.    
  583.     handles.lineRef = line(x,y,'Color','red','LineStyle','--','LineWidth',2);
  584.    
  585.     handles.lcrop = 0;
  586.     handles.rcrop = 0;
  587.     handles.tcrop = 0;
  588.     handles.bcrop = 0;
  589.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  590.     handles.g1Val = 2;
  591.     handles.g2Val = 4;
  592.     handles.medVal = 20;
  593.     handles.diff = 2;
  594.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  595.  
  596.     guidata(hObject,handles);
  597.    
  598.    
  599.    
  600.     [H,W] = size(img);
  601.  
  602.     [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  603.    
  604.     img_gau = imgaussfilt(img_crp,handles.g1Val);
  605.     img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  606.     [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  607.  
  608.     img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  609.     img_med = filt_diff(img_med,H,W,handles.diff);
  610.  
  611.     [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  612.     mrg = 60;
  613.     [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  614.  
  615.     img_gau = imgaussfilt(img_flt,handles.g2Val);
  616.     img_diff = filt_diff(img_gau,H,W,handles.diff);
  617.  
  618.     [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  619.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  620.     axes(handles.imgOutputAxes)
  621.     axis image
  622.     imshow(img_rl,[]);
  623.    
  624. end
  625.  
  626.  
  627. % --- Executes on slider movement.
  628. function rcropSlider_Callback(hObject, eventdata, handles)
  629. % hObject    handle to rcropSlider (see GCBO)
  630. % eventdata  reserved - to be defined in a future version of MATLAB
  631. % handles    structure with handles and user data (see GUIDATA)
  632.  
  633. % Hints: get(hObject,'Value') returns position of slider
  634. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  635. r_crop_normalized = get(handles.rcropSlider,'Value');
  636.  
  637. filePath = handles.filePath;
  638. imgFilePath = handles.imgFolderInfo;
  639. imgName = imgFilePath(handles.imgOrder).name;
  640.  
  641. img = imread([filePath,'\',imgName]);
  642. [H,W] = size(img);
  643.  
  644. % l_crop = 0;
  645. r_crop = r_crop_normalized*W;
  646. % t_crop = 0;
  647. % b_crop = 0;
  648.  
  649. handles.rcrop = r_crop;
  650. guidata(hObject,handles);
  651.  
  652. [img_crp,H,W] = crop(img,H,W,int16(handles.lcrop),int16(handles.rcrop),int16(handles.tcrop),int16(handles.bcrop));
  653.  
  654. axes(handles.axes1)
  655. axis off
  656. axis image
  657. imshow(img_crp);
  658.  
  659.  
  660.  
  661. [H,W] = size(img);
  662.  
  663. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  664.  
  665. img_gau = imgaussfilt(img_crp,handles.g1Val);
  666. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  667. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  668.  
  669. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  670. img_med = filt_diff(img_med,H,W,handles.diff);
  671.  
  672. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  673. mrg = 60;
  674. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  675.  
  676. img_gau = imgaussfilt(img_flt,handles.g2Val);
  677. img_diff = filt_diff(img_gau,H,W,handles.diff);
  678.  
  679. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  680. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  681. axes(handles.imgOutputAxes)
  682. axis image
  683. imshow(img_rl,[]);
  684.  
  685.  
  686. % --- Executes during object creation, after setting all properties.
  687. function rcropSlider_CreateFcn(hObject, eventdata, handles)
  688. % hObject    handle to rcropSlider (see GCBO)
  689. % eventdata  reserved - to be defined in a future version of MATLAB
  690. % handles    empty - handles not created until after all CreateFcns called
  691.  
  692. % Hint: slider controls usually have a light gray background.
  693. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  694.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  695. end
  696.  
  697.  
  698. % --- Executes on slider movement.
  699. function lcropSlider_Callback(hObject, eventdata, handles)
  700. % hObject    handle to lcropSlider (see GCBO)
  701. % eventdata  reserved - to be defined in a future version of MATLAB
  702. % handles    structure with handles and user data (see GUIDATA)
  703.  
  704. % Hints: get(hObject,'Value') returns position of slider
  705. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  706. l_crop_normalized = get(handles.lcropSlider,'Value')
  707.  
  708. filePath = handles.filePath;
  709. imgFilePath = handles.imgFolderInfo;
  710. imgName = imgFilePath(handles.imgOrder).name;
  711.  
  712. img = imread([filePath,'\',imgName]);
  713. [H,W] = size(img);
  714.  
  715. l_crop = l_crop_normalized*W;
  716. % r_crop = 0;
  717. % t_crop = 0;
  718. % b_crop = 0;
  719.  
  720. handles.lcrop = l_crop;
  721. guidata(hObject,handles);
  722.  
  723. [img_crp,H,W] = crop(img,H,W,int16(handles.lcrop),int16(handles.rcrop),int16(handles.tcrop),int16(handles.bcrop));
  724.  
  725. axes(handles.axes1)
  726. axis off
  727. axis image
  728. imshow(img_crp);
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735. [H,W] = size(img);
  736.  
  737. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  738.  
  739. img_gau = imgaussfilt(img_crp,handles.g1Val);
  740. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  741. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  742.  
  743. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  744. img_med = filt_diff(img_med,H,W,handles.diff);
  745.  
  746. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  747. mrg = 60;
  748. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  749.  
  750. img_gau = imgaussfilt(img_flt,handles.g2Val);
  751. img_diff = filt_diff(img_gau,H,W,handles.diff);
  752.  
  753. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  754. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  755. axes(handles.imgOutputAxes)
  756. axis image
  757. imshow(img_rl,[]);
  758.  
  759.  
  760.  
  761. % --- Executes during object creation, after setting all properties.
  762. function lcropSlider_CreateFcn(hObject, eventdata, handles)
  763. % hObject    handle to lcropSlider (see GCBO)
  764. % eventdata  reserved - to be defined in a future version of MATLAB
  765. % handles    empty - handles not created until after all CreateFcns called
  766.  
  767. % Hint: slider controls usually have a light gray background.
  768. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  769.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  770. end
  771.  
  772.  
  773. % --- Executes on slider movement.
  774. function tcropSlider_Callback(hObject, eventdata, handles)
  775. % hObject    handle to tcropSlider (see GCBO)
  776. % eventdata  reserved - to be defined in a future version of MATLAB
  777. % handles    structure with handles and user data (see GUIDATA)
  778.  
  779. % Hints: get(hObject,'Value') returns position of slider
  780. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  781. t_crop_normalized = get(handles.tcropSlider,'Value');
  782.  
  783. filePath = handles.filePath;
  784. imgFilePath = handles.imgFolderInfo;
  785. imgName = imgFilePath(handles.imgOrder).name;
  786.  
  787. img = imread([filePath,'\',imgName]);
  788. [H,W] = size(img);
  789.  
  790.  
  791. t_crop = t_crop_normalized*W;
  792.  
  793. handles.tcrop = t_crop;
  794. guidata(hObject,handles);
  795.  
  796. [img_crp,H,W] = crop(img,H,W,int16(handles.lcrop),int16(handles.rcrop),int16(handles.tcrop),int16(handles.bcrop));
  797.  
  798. axes(handles.axes1)
  799. axis off
  800. axis image
  801. imshow(img_crp);
  802.  
  803.  
  804.  
  805.  
  806. [H,W] = size(img);
  807.  
  808. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  809.  
  810. img_gau = imgaussfilt(img_crp,handles.g1Val);
  811. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  812. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  813.  
  814. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  815. img_med = filt_diff(img_med,H,W,handles.diff);
  816.  
  817. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  818. mrg = 60;
  819. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  820.  
  821. img_gau = imgaussfilt(img_flt,handles.g2Val);
  822. img_diff = filt_diff(img_gau,H,W,handles.diff);
  823.  
  824. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  825. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  826. axes(handles.imgOutputAxes)
  827. axis image
  828. imshow(img_rl,[]);
  829.  
  830.  
  831. % --- Executes during object creation, after setting all properties.
  832. function tcropSlider_CreateFcn(hObject, eventdata, handles)
  833. % hObject    handle to tcropSlider (see GCBO)
  834. % eventdata  reserved - to be defined in a future version of MATLAB
  835. % handles    empty - handles not created until after all CreateFcns called
  836.  
  837. % Hint: slider controls usually have a light gray background.
  838. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  839.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  840. end
  841.  
  842.  
  843. % --- Executes on slider movement.
  844. function bcropSlider_Callback(hObject, eventdata, handles)
  845. % hObject    handle to bcropSlider (see GCBO)
  846. % eventdata  reserved - to be defined in a future version of MATLAB
  847. % handles    structure with handles and user data (see GUIDATA)
  848.  
  849. % Hints: get(hObject,'Value') returns position of slider
  850. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  851. b_crop_normalized = get(handles.bcropSlider,'Value');
  852.  
  853. filePath = handles.filePath;
  854. imgFilePath = handles.imgFolderInfo;
  855. imgName = imgFilePath(handles.imgOrder).name;
  856.  
  857. img = imread([filePath,'\',imgName]);
  858. [H,W] = size(img);
  859.  
  860. % l_crop = 0;
  861. % r_crop = 0;
  862. % t_crop = 0;
  863. b_crop = b_crop_normalized*W;
  864.  
  865. handles.bcrop = b_crop;
  866. guidata(hObject,handles);
  867.  
  868. [img_crp,H,W] = crop(img,H,W,int16(handles.lcrop),int16(handles.rcrop),int16(handles.tcrop),int16(handles.bcrop));
  869.  
  870. axes(handles.axes1)
  871. axis off
  872. axis image
  873. imshow(img_crp);
  874.  
  875.  
  876.  
  877. [H,W] = size(img);
  878.  
  879. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  880.  
  881. img_gau = imgaussfilt(img_crp,handles.g1Val);
  882. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  883. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  884.  
  885. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  886. img_med = filt_diff(img_med,H,W,handles.diff);
  887.  
  888. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  889. mrg = 60;
  890. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  891.  
  892. img_gau = imgaussfilt(img_flt,handles.g2Val);
  893. img_diff = filt_diff(img_gau,H,W,handles.diff);
  894.  
  895. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  896. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  897. axes(handles.imgOutputAxes)
  898. axis image
  899. imshow(img_rl,[]);
  900.  
  901.  
  902.  
  903. % --- Executes during object creation, after setting all properties.
  904. function bcropSlider_CreateFcn(hObject, eventdata, handles)
  905. % hObject    handle to bcropSlider (see GCBO)
  906. % eventdata  reserved - to be defined in a future version of MATLAB
  907. % handles    empty - handles not created until after all CreateFcns called
  908.  
  909. % Hint: slider controls usually have a light gray background.
  910. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  911.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  912. end
  913.  
  914.  
  915. % --- Executes on slider movement.
  916. function slider8_Callback(hObject, eventdata, handles)
  917. % hObject    handle to slider8 (see GCBO)
  918. % eventdata  reserved - to be defined in a future version of MATLAB
  919. % handles    structure with handles and user data (see GUIDATA)
  920.  
  921. % Hints: get(hObject,'Value') returns position of slider
  922. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  923.  
  924.  
  925. % --- Executes during object creation, after setting all properties.
  926. function slider8_CreateFcn(hObject, eventdata, handles)
  927. % hObject    handle to slider8 (see GCBO)
  928. % eventdata  reserved - to be defined in a future version of MATLAB
  929. % handles    empty - handles not created until after all CreateFcns called
  930.  
  931. % Hint: slider controls usually have a light gray background.
  932. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  933.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  934. end
  935.  
  936.  
  937. % --- Executes on slider movement.
  938. function g1Slider_Callback(hObject, eventdata, handles)
  939. % hObject    handle to g1Slider (see GCBO)
  940. % eventdata  reserved - to be defined in a future version of MATLAB
  941. % handles    structure with handles and user data (see GUIDATA)
  942.  
  943. % Hints: get(hObject,'Value') returns position of slider
  944. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  945. handles.g1Val = get(handles.g1Slider,'Value');
  946. set(handles.g1ValLabel, 'String', handles.g1Val);
  947. guidata(hObject,handles);
  948.  
  949. % filePath = handles.filePath;
  950. imgFilePath = handles.imgFolderInfo;
  951. imgName = imgFilePath(handles.imgOrder).name;
  952.  
  953. img = imread([handles.filePath,'\',imgName]);
  954.    
  955.  
  956. [H,W] = size(img);
  957.  
  958. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  959.  
  960. img_gau = imgaussfilt(img_crp,handles.g1Val);
  961. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  962. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  963.  
  964. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  965. img_med = filt_diff(img_med,H,W,handles.diff);
  966.  
  967. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  968. mrg = 60;
  969. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  970.  
  971. img_gau = imgaussfilt(img_flt,handles.g2Val);
  972. img_diff = filt_diff(img_gau,H,W,handles.diff);
  973.  
  974. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  975. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  976. axes(handles.imgOutputAxes)
  977. axis image
  978. imshow(img_rl,[]);
  979.    
  980.  
  981.  
  982. % --- Executes during object creation, after setting all properties.
  983. function g1Slider_CreateFcn(hObject, eventdata, handles)
  984. % hObject    handle to g1Slider (see GCBO)
  985. % eventdata  reserved - to be defined in a future version of MATLAB
  986. % handles    empty - handles not created until after all CreateFcns called
  987.  
  988. % Hint: slider controls usually have a light gray background.
  989. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  990.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  991. end
  992.  
  993.  
  994. % --- Executes on slider movement.
  995. function g2Slider_Callback(hObject, eventdata, handles)
  996. % hObject    handle to g2Slider (see GCBO)
  997. % eventdata  reserved - to be defined in a future version of MATLAB
  998. % handles    structure with handles and user data (see GUIDATA)
  999.  
  1000. % Hints: get(hObject,'Value') returns position of slider
  1001. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  1002. handles.g2Val = get(handles.g2Slider,'Value');
  1003. set(handles.g2ValLabel, 'String', handles.g2Val);
  1004. guidata(hObject,handles);
  1005.  
  1006. % filePath = handles.filePath;
  1007. imgFilePath = handles.imgFolderInfo;
  1008. imgName = imgFilePath(handles.imgOrder).name;
  1009.  
  1010. img = imread([handles.filePath,'\',imgName]);
  1011.    
  1012.  
  1013. [H,W] = size(img);
  1014.  
  1015. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  1016.  
  1017. img_gau = imgaussfilt(img_crp,handles.g1Val);
  1018. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  1019. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  1020.  
  1021. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  1022. img_med = filt_diff(img_med,H,W,handles.diff);
  1023.  
  1024. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  1025. mrg = 60;
  1026. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  1027.  
  1028. img_gau = imgaussfilt(img_flt,handles.g2Val);
  1029. img_diff = filt_diff(img_gau,H,W,handles.diff);
  1030.  
  1031. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  1032. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1033. axes(handles.imgOutputAxes)
  1034. axis image
  1035. imshow(img_rl,[]);
  1036.  
  1037. % --- Executes during object creation, after setting all properties.
  1038. function g2Slider_CreateFcn(hObject, eventdata, handles)
  1039. % hObject    handle to g2Slider (see GCBO)
  1040. % eventdata  reserved - to be defined in a future version of MATLAB
  1041. % handles    empty - handles not created until after all CreateFcns called
  1042.  
  1043. % Hint: slider controls usually have a light gray background.
  1044. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1045.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  1046. end
  1047.  
  1048.  
  1049. % --- Executes on slider movement.
  1050. function medSlider_Callback(hObject, eventdata, handles)
  1051. % hObject    handle to medSlider (see GCBO)
  1052. % eventdata  reserved - to be defined in a future version of MATLAB
  1053. % handles    structure with handles and user data (see GUIDATA)
  1054.  
  1055. % Hints: get(hObject,'Value') returns position of slider
  1056. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  1057. handles.medVal = get(handles.medSlider,'Value');
  1058. set(handles.medValLabel, 'String', handles.medVal);
  1059. guidata(hObject,handles);
  1060.  
  1061. % filePath = handles.filePath;
  1062. imgFilePath = handles.imgFolderInfo;
  1063. imgName = imgFilePath(handles.imgOrder).name;
  1064.  
  1065. img = imread([handles.filePath,'\',imgName]);
  1066.    
  1067.  
  1068. [H,W] = size(img);
  1069.  
  1070. [img_crp,H,W] = crop(img,H,W,handles.lcrop,handles.rcrop,handles.tcrop,handles.bcrop);
  1071.  
  1072. img_gau = imgaussfilt(img_crp,handles.g1Val);
  1073. img_diff_bef = filt_diff(img_gau,H,W,handles.diff);
  1074. [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  1075.  
  1076. img_med = medfilt2(img_gau,[handles.medVal*2 handles.medVal*2],'symmetric');
  1077. img_med = filt_diff(img_med,H,W,handles.diff);
  1078.  
  1079. [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  1080. mrg = 60;
  1081. [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  1082.  
  1083. img_gau = imgaussfilt(img_flt,handles.g2Val);
  1084. img_diff = filt_diff(img_gau,H,W,handles.diff);
  1085.  
  1086. [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  1087. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1088. axes(handles.imgOutputAxes)
  1089. axis image
  1090. imshow(img_rl,[]);
  1091.  
  1092. % --- Executes during object creation, after setting all properties.
  1093. function medSlider_CreateFcn(hObject, eventdata, handles)
  1094. % hObject    handle to medSlider (see GCBO)
  1095. % eventdata  reserved - to be defined in a future version of MATLAB
  1096. % handles    empty - handles not created until after all CreateFcns called
  1097.  
  1098. % Hint: slider controls usually have a light gray background.
  1099. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1100.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  1101. end
Advertisement
Add Comment
Please, Sign In to add comment