tuttelikz

gui_replica_matlab [backup before v2]

Dec 25th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 32.41 KB | None | 0 0
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%THIs is main working
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%now
  3. function varargout = gui_replica(varargin)
  4. % gui_replica MATLAB code for gui_replica.fig
  5. %      gui_replica, by itself, creates a new gui_replica or raises the existing
  6. %      singleton*.
  7. %
  8. %      H = gui_replica returns the handle to a new gui_replica or the handle to
  9. %      the existing singleton*.
  10. %
  11. %      gui_replica('CALLBACK',hObject,eventData,handles,...) calls the local
  12. %      function named CALLBACK in gui_replica.M with the given input arguments.
  13. %
  14. %      gui_replica('Property','Value',...) creates a new gui_replica or raises the
  15. %      existing singleton*.  Starting from the left, property value pairs are
  16. %      applied to the GUI before gui_replica_OpeningFcn gets called.  An
  17. %      unrecognized property name or invalid value makes property application
  18. %      stop.  All inputs are passed to gui_replica_OpeningFcn via varargin.
  19. %
  20. %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  21. %      instance to run (singleton)".
  22. %
  23. % See also: GUIDE, GUIDATA, GUIHANDLES
  24.  
  25. % Edit the above text to modify the response to help gui_replica
  26.  
  27. % Last Modified by GUIDE v2.5 21-Dec-2017 20:59:26
  28.  
  29. % Begin initialization code - DO NOT EDIT
  30. gui_Singleton = 1;
  31. gui_State = struct('gui_Name',       mfilename, ...
  32.                    'gui_Singleton',  gui_Singleton, ...
  33.                    'gui_OpeningFcn', @gui_replica_OpeningFcn, ...
  34.                    'gui_OutputFcn',  @gui_replica_OutputFcn, ...
  35.                    'gui_LayoutFcn',  [] , ...
  36.                    'gui_Callback',   []);
  37. if nargin && ischar(varargin{1})
  38.     gui_State.gui_Callback = str2func(varargin{1});
  39. end
  40.  
  41. if nargout
  42.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  43. else
  44.     gui_mainfcn(gui_State, varargin{:});
  45. end
  46. % End initialization code - DO NOT EDIT
  47.  
  48.  
  49. % --- Executes just before gui_replica is made visible.
  50. function gui_replica_OpeningFcn(hObject, eventdata, handles, varargin)
  51. % This function has no output args, see OutputFcn.
  52. % hObject    handle to figure
  53. % eventdata  reserved - to be defined in a future version of MATLAB
  54. % handles    structure with handles and user data (see GUIDATA)
  55. % varargin   command line arguments to gui_replica (see VARARGIN)
  56. handles.output = hObject;
  57.  
  58. % Update handles structure
  59. guidata(hObject, handles);
  60.  
  61.  
  62.  
  63. % img = imread('logo-tbl.png');
  64. % axes(handles.axes4)
  65. % imshow(img)
  66. % axis off
  67. % axis image
  68. % % Choose default command line output for gui_replica
  69. % handles.output = hObject;
  70. %
  71. % % Update handles structure
  72. % guidata(hObject, handles);
  73.  
  74. % UIWAIT makes gui_replica wait for user response (see UIRESUME)
  75. % uiwait(handles.figure1);
  76.  
  77.  
  78. % --- Outputs from this function are returned to the command line.
  79. function varargout = gui_replica_OutputFcn(hObject, eventdata, handles)
  80. % varargout  cell array for returning output args (see VARARGOUT);
  81. % hObject    handle to figure
  82. % eventdata  reserved - to be defined in a future version of MATLAB
  83. % handles    structure with handles and user data (see GUIDATA)
  84.  
  85. % Get default command line output from handles structure
  86. % varargout{1} = handles.output;
  87. varargout{1} = handles.output;
  88.  
  89.  
  90. % --- Executes on button press in pushbutton1.
  91. function pushbutton1_Callback(hObject, eventdata, handles)
  92. % hObject    handle to pushbutton1 (see GCBO)
  93. % eventdata  reserved - to be defined in a future version of MATLAB
  94. % handles    structure with handles and user data (see GUIDATA)
  95.  
  96.  
  97.  
  98.  
  99. % [file_name,path_name] = uigetfile('*.jpg','Select image file');
  100. % full_path = [path_name,'\',file_name];
  101. % handles.filename=full_path;
  102. % guidata(hObject,handles)
  103. % img = imread(full_path);
  104. % axes(handles.axes1)
  105. % imshow(img)
  106. % axis off
  107. % axis image
  108.  
  109.  
  110.  
  111.  
  112.  
  113. % --- Executes on button press in btnChooseSample.
  114. function btnChooseSample_Callback(hObject, eventdata, handles)
  115. % hObject    handle to btnChooseSample (see GCBO)
  116. % eventdata  reserved - to be defined in a future version of MATLAB
  117. % handles    structure with handles and user data (see GUIDATA)
  118.  
  119.  
  120. modeSelectedObj = get(handles.modeSelection,'SelectedObject')
  121. modeSelectedLabel = get(modeSelectedObj,'String')
  122.  
  123.  
  124. if (strcmp(modeSelectedLabel,'Single Mode') == 1)
  125.     [FileName,PathName] = uigetfile('*.jpg','Select the image file');
  126.     img = imread(FileName);
  127.     [H,W] = size(img);
  128.  
  129.     t_crop = 80;
  130.     r_crop = 55;
  131.     b_crop = 700;
  132.     l_crop = 105;
  133.     % %
  134.     [img_crp,H,W] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
  135.     %
  136.     %
  137.     % img_crop = img(t_crop+1:H-b_crop,l_crop+1:W-r_crop);
  138.     % [H_crop,W_crop] = size(img_crop);
  139.  
  140.  
  141.     gsigma1 = 2; %gsigma1_arr(sbj_no,part_no);
  142.     %gsigma1 = 25;
  143.     %img_gau = img_crp;
  144.     img_gau = imgaussfilt(img_crp,gsigma1);
  145.     diff_rl = 2;
  146.     img_diff_bef = filt_diff(img_gau,H,W,diff_rl);
  147.     [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  148.  
  149.  
  150.     med = 20; %med_arr(sbj_no,part_no); %med_arr(sbj_no,part_no); %60
  151.     diff_idl = 2;
  152.     %med = 10;
  153.     img_med = medfilt2(img_gau,[med*2 med*2],'symmetric');
  154.     %             figure()
  155.     %             imshow(img_med,[]);
  156.  
  157.     img_med = filt_diff(img_med,H,W,diff_idl);
  158.     %             figure()
  159.     %             imshow(img_med,[]);
  160.  
  161.     [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  162.     mrg = 10;
  163.     [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  164.     gsigma2 = 4; %gsigma2_arr(sbj_no,part_no); %60 gsigma_arr(sbj_no,part_no);
  165.     %             gsigma = 10; %11
  166.     img_gau = imgaussfilt(img_flt,gsigma2);
  167.     diff_rl = 2;
  168.     img_diff = filt_diff(img_gau,H,W,diff_rl);
  169.     % figure()
  170.     % imshow(img_diff,[]);
  171.     [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  172.     [avg_rgh,rms_rgh,max_rgh] = rgh_single(avg_rl,ind_rl);
  173.  
  174.  
  175. %     axes(handles.axes6)
  176. %     imshow(img_crp);
  177. %     axis off
  178. %     axis image
  179.  
  180.     axes(handles.outputImage)
  181.     imshow(img_rl,[]);
  182.     axis off
  183.     axis image
  184.  
  185.     text_avg_rough_front = sprintf('%.2f', avg_rgh);
  186.     text_rms_rough_front = sprintf('%.2f', rms_rgh);
  187.     text_max_rough_front = sprintf('%.2f', max_rgh);
  188.  
  189.     set(handles.avgValueText, 'String', text_avg_rough_front);
  190.     set(handles.rmsValueText, 'String', text_rms_rough_front);
  191.     set(handles.maxValueText, 'String', text_max_rough_front);
  192.    
  193.  
  194. elseif (strcmp(modeSelectedLabel,'Batch Mode') == 1)
  195.    
  196.     OpenfilePath = uigetdir;
  197.     max_step = 500;
  198.  
  199.     avg_rough_front = zeros(1,max_step);
  200.     rms_rough_front = zeros(1,max_step);
  201.     max_rough_front = zeros(1,max_step);
  202.  
  203.     t_crop = 20;
  204.     r_crop = 55;
  205.     b_crop = 500;
  206.     l_crop = 110;
  207.  
  208.     img_name = strcat('Image',num2str(2,'%04d'),'.jpg');
  209.     img = imread([OpenfilePath,'\',img_name]);
  210.     [H,W] = size(img);
  211.     %[img_crp,H,W] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
  212.     img3d = zeros(H,W,max_step,'uint8');
  213.  
  214.     for step = 1:max_step
  215.         %file_name = strcat('bb _',num,'.jpg');
  216.         %img_name = strcat('Image',num2str(2,'%04d'),'.jpg');
  217.         img_name = strcat('Image',num2str(step-1,'%04d'),'.jpg');
  218.         img = imread([OpenfilePath,'\',img_name]);
  219.         img3d(:,:,step) = img;
  220.  
  221.         [H,W] = size(img);
  222.  
  223.         t_crop = 80;
  224.         r_crop = 55;
  225.         b_crop = 700;
  226.         l_crop = 105;
  227.         % %
  228.         [img_crp,H,W] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
  229.         %
  230.         %
  231.         % img_crop = img(t_crop+1:H-b_crop,l_crop+1:W-r_crop);
  232.         % [H_crop,W_crop] = size(img_crop);
  233.  
  234.  
  235.         gsigma1 = 2; %gsigma1_arr(sbj_no,part_no);
  236.         %gsigma1 = 25;
  237.         %img_gau = img_crp;
  238.         img_gau = imgaussfilt(img_crp,gsigma1);
  239.         diff_rl = 2;
  240.         img_diff_bef = filt_diff(img_gau,H,W,diff_rl);
  241.         [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W); %img_rl
  242.  
  243.  
  244.         med = 20; %med_arr(sbj_no,part_no); %med_arr(sbj_no,part_no); %60
  245.         diff_idl = 2;
  246.         %med = 10;
  247.         img_med = medfilt2(img_gau,[med*2 med*2],'symmetric');
  248.         %             figure()
  249.         %             imshow(img_med,[]);
  250.  
  251.         img_med = filt_diff(img_med,H,W,diff_idl);
  252.         %             figure()
  253.         %             imshow(img_med,[]);
  254.  
  255.         [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  256.         mrg = 10;
  257.         [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  258.         gsigma2 = 4; %gsigma2_arr(sbj_no,part_no); %60 gsigma_arr(sbj_no,part_no);
  259.         %             gsigma = 10; %11
  260.         img_gau = imgaussfilt(img_flt,gsigma2);
  261.         diff_rl = 2;
  262.         img_diff = filt_diff(img_gau,H,W,diff_rl);
  263.         % figure()
  264.         % imshow(img_diff,[]);
  265.         [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  266.         %[avg_rgh,rms_rgh,max_rgh] = rgh_single(avg_rl,ind_rl);
  267.         [avg_rough_front(step),rms_rough_front(step),max_rough_front(step)] = rgh(avg_rl,ind_rl);
  268.  
  269.     end
  270.  
  271.     mean_avg_rgh_front = mean(avg_rough_front);
  272.     mean_rms_rgh_front = mean(rms_rough_front);
  273.     mean_max_rgh_front = mean(max_rough_front);
  274.  
  275.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  276. %     text_avg_rough_front = sprintf('%.2f', mean_avg_rgh_front);
  277. %     text_rms_rough_front = sprintf('%.2f', mean_rms_rgh_front);
  278. %     text_max_rough_front = sprintf('%.2f', mean_max_rgh_front);
  279. %
  280. %     set(handles.frontAvgValueText, 'String', text_avg_rough_front);
  281. %     set(handles.frontRMSValueText, 'String', text_rms_rough_front);
  282. %     set(handles.frontMaxValueText, 'String', text_max_rough_front);
  283.  
  284.  
  285.  
  286.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  287.  
  288.  
  289.     [H,W,I] = size(img3d);
  290.     max_iter = W;
  291.     avg_rough_side = zeros(1,max_iter);
  292.     rms_rough_side = zeros(1,max_iter);
  293.     max_rough_side = zeros(1,max_iter);
  294.  
  295.     for img_no = 1:1 %200
  296.         avgSide = img3d(:,img_no,:);
  297.             % avgSide = avgSide([20:H-400],:); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  298.         avgSide2 = squeeze(avgSide);
  299.         img = avgSide2;
  300.  
  301.         [H,W] = size(img);
  302.  
  303.         gsigma1 = 2; %gsigma1_arr(sbj_no,part_no);
  304.         img_gau = imgaussfilt(img,gsigma1);
  305.  
  306.         med = 20; %med_arr(sbj_no,part_no); %med_arr(sbj_no,part_no); %60
  307.         diff_idl = 2;
  308.         img_med = medfilt2(img_gau,[med*2 med*2],'symmetric');
  309.         img_med = filt_diff(img_med,H,W,diff_idl);
  310.         [img_idl,ind_idl,~] = find_srf(img_med,H,W);    
  311.  
  312.         mrg = 60;
  313.         [img_flt,H,W] = flatten(img,H,W,ind_idl,mrg);
  314.  
  315.         gsigma2 = 4; %gsigma2_arr(sbj_no,part_no);
  316.         img_gau = imgaussfilt(img_flt,gsigma2);
  317.  
  318.         diff_rl = 2;
  319.         img_diff = filt_diff(img_gau,H,W,diff_rl);
  320.  
  321.         [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  322.  
  323.         [avg_rough_side(img_no),rms_rough_side(img_no),max_rough_side(img_no)] = rgh(avg_rl,ind_rl);
  324.     end
  325.    
  326.     mean_avg_rgh_side = mean(avg_rough_side);
  327.     mean_rms_rgh_side = mean(rms_rough_side);
  328.     mean_max_rgh_side = mean(max_rough_side);
  329.  
  330.  
  331.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  332. %     text_avg_rough_side = sprintf('%.4f', mean_avg_rgh_side);
  333. %     text_rms_rough_side = sprintf('%.4f', mean_rms_rgh_side);
  334. %     text_max_rough_sidet = sprintf('%.4f', mean_max_rgh_side);
  335. %
  336. %     set(handles.sideAvgValueText, 'String', text_avg_rough_side);
  337. %     set(handles.sideRMSValueText, 'String', text_rms_rough_side);
  338. %     set(handles.sideMaxValueText, 'String', text_max_rough_sidet);
  339.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%s
  340.  
  341.     axes(handles.outputImage)
  342.     imshow(img_rl,[]);
  343.     axis off
  344.     axis image
  345.  
  346.  
  347.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  348.     avg_area_rgh = mean_avg_rgh_front * mean_avg_rgh_side;
  349.     rms_area_rgh = mean_rms_rgh_front * mean_rms_rgh_side;
  350.     max_area_rgh = max(mean_max_rgh_front,mean_max_rgh_side);
  351.  
  352.     text_avg_area_rgh = sprintf('%.4f', avg_area_rgh);
  353.     text_rms_area_rgh = sprintf('%.4f', rms_area_rgh);
  354.     text_max_area_rgh = sprintf('%.4f', max_area_rgh);
  355.    
  356.     set(handles.avgValueText, 'String', text_avg_area_rgh);
  357.     set(handles.rmsValueText, 'String', text_rms_area_rgh);
  358.     set(handles.maxValueText, 'String', text_max_area_rgh);
  359.    
  360. %     set(handles.avgAreaRgh, 'String', text_avg_area_rgh);
  361. %     set(handles.rmsAreaRgh, 'String', text_rms_area_rgh);
  362. %     set(handles.maxAreaRgh, 'String', text_max_area_rgh);
  363.  
  364. else
  365. end
  366.  
  367.  
  368.    
  369.    
  370.    
  371.    
  372.    
  373.    
  374.    
  375.    
  376.    
  377.    
  378.    
  379.    
  380.    
  381.    
  382.  
  383.    
  384.    
  385.    
  386.    
  387.    
  388.    
  389.    
  390.    
  391.    
  392.    
  393.    
  394.    
  395.    
  396.    
  397.    
  398.    
  399.    
  400.    
  401.    
  402.    
  403.    
  404.    
  405.    
  406.    
  407.    
  408.    
  409.    
  410.    
  411.    
  412.    
  413.    
  414.    
  415.    
  416.    
  417.    
  418.    
  419.    
  420.    
  421.    
  422.    
  423.    
  424.    
  425.    
  426.    
  427.    
  428.    
  429.    
  430.    
  431.    
  432.    
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439. % --- Executes on button press in pushbutton3.
  440. function pushbutton3_Callback(hObject, eventdata, handles)
  441. % hObject    handle to pushbutton3 (see GCBO)
  442. % eventdata  reserved - to be defined in a future version of MATLAB
  443. % handles    structure with handles and user data (see GUIDATA)
  444.  
  445.  
  446. % --- Executes on button press in pushbutton4.
  447. function pushbutton4_Callback(hObject, eventdata, handles)
  448. % hObject    handle to pushbutton4 (see GCBO)
  449. % eventdata  reserved - to be defined in a future version of MATLAB
  450. % handles    structure with handles and user data (see GUIDATA)
  451.  
  452.  
  453.  
  454. % --- Executes on button press in pushbutton5.
  455. function pushbutton5_Callback(hObject, eventdata, handles)
  456. % hObject    handle to pushbutton5 (see GCBO)
  457. % eventdata  reserved - to be defined in a future version of MATLAB
  458. % handles    structure with handles and user data (see GUIDATA)
  459.  
  460.  
  461. % --- Executes on button press in pushbutton6.
  462. function pushbutton6_Callback(hObject, eventdata, handles)
  463. % hObject    handle to pushbutton6 (see GCBO)
  464. % eventdata  reserved - to be defined in a future version of MATLAB
  465. % handles    structure with handles and user data (see GUIDATA)
  466.  
  467.  
  468. % --- Executes on button press in pushbutton7.
  469. function pushbutton7_Callback(hObject, eventdata, handles)
  470. % hObject    handle to pushbutton7 (see GCBO)
  471. % eventdata  reserved - to be defined in a future version of MATLAB
  472. % handles    structure with handles and user data (see GUIDATA)
  473.  
  474.  
  475. % --- Executes during object creation, after setting all properties.
  476. function text21_CreateFcn(hObject, eventdata, handles)
  477. % hObject    handle to text21 (see GCBO)
  478. % eventdata  reserved - to be defined in a future version of MATLAB
  479. % handles    empty - handles not created until after all CreateFcns called
  480.  
  481.  
  482. % --- Executes during object creation, after setting all properties.
  483. function axes1_CreateFcn(hObject, eventdata, handles)
  484. % hObject    handle to axes1 (see GCBO)
  485. % eventdata  reserved - to be defined in a future version of MATLAB
  486. % handles    empty - handles not created until after all CreateFcns called
  487.  
  488. % Hint: place code in OpeningFcn to populate axes1
  489.  
  490.  
  491. % --- Executes during object deletion, before destroying properties.
  492. function axes1_DeleteFcn(hObject, eventdata, handles)
  493. % hObject    handle to axes1 (see GCBO)
  494. % eventdata  reserved - to be defined in a future version of MATLAB
  495. % handles    structure with handles and user data (see GUIDATA)
  496.  
  497.  
  498. % --- Executes on mouse press over axes background.
  499. function axes1_ButtonDownFcn(hObject, eventdata, handles)
  500. % hObject    handle to axes1 (see GCBO)
  501. % eventdata  reserved - to be defined in a future version of MATLAB
  502. % handles    structure with handles and user data (see GUIDATA)
  503.  
  504.  
  505. % --- Executes on button press in pushbutton8.
  506. function pushbutton8_Callback(hObject, eventdata, handles)
  507. % hObject    handle to pushbutton8 (see GCBO)
  508. % eventdata  reserved - to be defined in a future version of MATLAB
  509. % handles    structure with handles and user data (see GUIDATA)
  510.  
  511.  
  512.  
  513.  
  514. % img = imread('logo-tbl.png');
  515. % axes(handles.axes4)
  516. % imshow(img)
  517. % axis off
  518. % axis image
  519.    
  520.  
  521. % gsigma1 = 2; %gsigma1_arr(sbj_no,part_no);
  522. % img_crp = uint8(img_crp);
  523. % img_gau = imgaussfilt(img_crp,gsigma1);    
  524. % diff_rl = 2;
  525. % img_diff_bef = filt_diff(img_gau,H,W,diff_rl);
  526. % [img_rl_bef,ind_rl_bef,avg_rl_bef] = find_srf(img_diff_bef,H,W);
  527. % med = 20; %med_arr(sbj_no,part_no);
  528. % diff_idl = 2;
  529. % img_med = medfilt2(img_gau,[med*2 med*2],'symmetric');
  530. % img_med = filt_diff(img_med,H,W,diff_idl);
  531. % [img_idl,ind_idl,~] = find_srf(img_med,H,W);
  532. % mrg = 10;
  533. % [img_flt,H,W] = flatten(img_crp,H,W,ind_idl,mrg);
  534. % gsigma2 = 4; %gsigma2_arr(sbj_no,part_no); %60 gsigma_arr(sbj_no,part_no);
  535. % img_gau = imgaussfilt(img_flt,gsigma2);
  536. %
  537. % diff_rl = 2;
  538. % img_diff = filt_diff(img_gau,H,W,diff_rl);
  539. % % figure()
  540. % % imshow(img_diff,[]);
  541. % [img_rl,ind_rl,avg_rl] = find_srf(img_diff,H,W); %img_rl
  542. %
  543. % axes(handles.axes1)
  544. % imshow(img_rl,[]);
  545.  
  546. % figure()
  547. % imshow(img_rl,[]);
  548.  
  549.  
  550.  
  551. % axis off
  552. % axis image
  553.  
  554. %imshow(img)
  555.  
  556.  
  557.  
  558. % axes(handles.outputImage)
  559. % %imshow(img)
  560. % axis off
  561. % axis image
  562. % imshow(cat(3,r1,g1,b1),[]);
  563.  
  564.  
  565.  
  566. % OpenfilePath = 'C:\Users\TBL\Documents\MATLAB\Yujin_Data\20170404_Amore_Replica\Eye-rim\5-Y';
  567.  
  568.  
  569. % img_name = strcat('Image',num2str(img_no-1,'%04d'),'.jpg');
  570. %
  571. % img0 = imread([OpenfilePath,'\',file_name]);
  572. %
  573. % img = imread(strcat(fld_pth,img_name));
  574.            
  575.  
  576.  
  577.  
  578.  
  579.  
  580. % max_step = 994;
  581. % avg_rough = zeros(1,max_step);
  582. % rms_rough = zeros(1,max_step);
  583. % max_rough = zeros(1,max_step);
  584. % total_rough = zeros(1,max_step);
  585. %
  586. % % full_path = handles.filename;
  587. % diff = 2;
  588. % l_crop = 156;
  589. % r_crop = 10;
  590. % t_crop = 45;
  591. % b_crop = 5;
  592. %
  593. % for step = 1:max_step
  594. %     offset = 6;
  595. %     num = sprintf('%d',step+offset);
  596. %     file_name = strcat('bb _',num,'.jpg');
  597. %     img0 = imread([OpenfilePath,'\',file_name]);
  598. %     img = rgb2gray(img0);
  599. %     [H,W] = size(img);
  600. %     img = flip(img, 1);
  601. %     [img_crop,H_crop,W_crop] = crop(img,H,W,l_crop,r_crop,t_crop,b_crop);
  602. %     img_filt = imgaussfilt(img_crop,6);
  603. %     img_diff = filt_diff(img_filt,H_crop,W_crop,diff);
  604. %    
  605. %     %ref_line to ref+line_surf
  606. %     [img_line_surf,ind_line_surf,avg_index,ref_line_surf] = line_surf2(img_diff,H_crop,W_crop,diff);
  607. %     img3d(:,:,step) = img_line_surf;
  608. %
  609. %     [peak_height_front,valley_depth_front] = peak_valley(ind_line_surf,avg_index,W_crop);
  610. %     [avg_rough_front(step),rms_rough_front(step),max_rough_front(step),total_rough_front(step)] = roughness(peak_height_front,valley_depth_front);
  611. %
  612. %     fprintf('%d\n', step);
  613. %
  614. % end
  615. %
  616. % avg_roughness = zeros(1,W_crop);
  617. % rms_roughness = zeros(1,W_crop);
  618. % max_roughness = zeros(1,W_crop);
  619. % total_roughness = zeros(1,W_crop);
  620. %
  621. % for ii = 1:W_crop
  622. %     s = img3d(:,ii,:);
  623. %     s = squeeze(s);
  624. %     [Hs,Ws] = size(s);
  625. %     [row,col] = find(s);
  626. %
  627. %     avg_index_side = round(mean(row));
  628. %     ref_line = zeros(Hs,Ws);
  629. %     ref_line(avg_index_side,:) = 255;
  630. %
  631. %     abs_roughness = zeros(1,Ws);
  632. %    
  633. %     [peak_height_side,valley_depth_side] = peak_valley(row,avg_index_side,W_crop);
  634. %     [avg_rough_side(ii),rms_rough_side(ii),max_rough_side(ii),total_rough_side(ii)] = roughness(peak_height_side,valley_depth_side);
  635. %    
  636. %     fprintf('%d\n', ii);
  637. %  
  638. % end
  639. %
  640. %
  641. %
  642. % %mean_avg_rough_front = mean(avg_rough_front)
  643. % % mean_rms_rough_front = mean(rms_rough_front)
  644. % % mean_max_rough_front = mean(max_rough_front)
  645. % % mean_total_rough_front = mean(total_rough_front)
  646. % disp('Front view roughness');
  647. %
  648. % text_avg_rough_front = sprintf('%.2f', mean(avg_rough_front));
  649. % text_rms_rough_front = sprintf('%.2f', mean(rms_rough_front));
  650. % text_max_rough_front = sprintf('%.2f', mean(max_rough_front));
  651. % text_total_rough_front = sprintf('%.2f', mean(total_rough_front));
  652. %
  653. % set(handles.avgValueText, 'String', text_avg_rough_front);
  654. % set(handles.rmsValueText, 'String', text_rms_rough_front);
  655. % set(handles.maxValueText, 'String', text_max_rough_front);
  656. % set(handles.text16, 'String', text_total_rough_front);
  657. %
  658. %
  659. % disp('Side view roughness');
  660. %
  661. % text_avg_rough = sprintf('%.2f', mean(avg_rough_side));
  662. % text_rms_rough = sprintf('%.2f', mean(rms_rough_side));
  663. % text_max_rough = sprintf('%.2f', mean(max_rough_side));
  664. % text_total_rough = sprintf('%.2f', mean(total_rough_side));
  665. %
  666. % set(handles.sideAvgValueText, 'String', text_avg_rough);
  667. % set(handles.sideRMSValueText, 'String', text_rms_rough);
  668. % set(handles.sideMaxValueText, 'String', text_max_rough);
  669. % set(handles.text30, 'String', text_total_rough);
  670. %
  671. %
  672. %
  673. %
  674. % axes(handles.axes1)
  675. % %imshow(img)
  676. % axis off
  677. % axis image
  678. % imshow(img0);
  679. %
  680. %
  681. % r1 = img_crop;
  682. % g1 = r1;
  683. % b1 = r1;
  684. % r1(img_line_surf > 0) = 255;
  685. % g1(img_line_surf > 0) = 0; %%
  686. % b1(ref_line_surf > 0) = 255; %
  687. %
  688. % axes(handles.outputImage)
  689. % %imshow(img)
  690. % axis off
  691. % axis image
  692. % imshow(cat(3,r1,g1,b1),[]);
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699. function edit2_Callback(hObject, eventdata, handles)
  700. % hObject    handle to edit2 (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,'String') returns contents of edit2 as text
  705. %        str2double(get(hObject,'String')) returns contents of edit2 as a double
  706.  
  707.  
  708. % --- Executes during object creation, after setting all properties.
  709. function edit2_CreateFcn(hObject, eventdata, handles)
  710. % hObject    handle to edit2 (see GCBO)
  711. % eventdata  reserved - to be defined in a future version of MATLAB
  712. % handles    empty - handles not created until after all CreateFcns called
  713.  
  714. % Hint: edit controls usually have a white background on Windows.
  715. %       See ISPC and COMPUTER.
  716. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  717.     set(hObject,'BackgroundColor','white');
  718. end
  719.  
  720.  
  721.  
  722. function edit3_Callback(hObject, eventdata, handles)
  723. % hObject    handle to edit3 (see GCBO)
  724. % eventdata  reserved - to be defined in a future version of MATLAB
  725. % handles    structure with handles and user data (see GUIDATA)
  726.  
  727. % Hints: get(hObject,'String') returns contents of edit3 as text
  728. %        str2double(get(hObject,'String')) returns contents of edit3 as a double
  729.  
  730.  
  731. % --- Executes during object creation, after setting all properties.
  732. function edit3_CreateFcn(hObject, eventdata, handles)
  733. % hObject    handle to edit3 (see GCBO)
  734. % eventdata  reserved - to be defined in a future version of MATLAB
  735. % handles    empty - handles not created until after all CreateFcns called
  736.  
  737. % Hint: edit controls usually have a white background on Windows.
  738. %       See ISPC and COMPUTER.
  739. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  740.     set(hObject,'BackgroundColor','white');
  741. end
  742.  
  743.  
  744.  
  745. function edit4_Callback(hObject, eventdata, handles)
  746. % hObject    handle to edit4 (see GCBO)
  747. % eventdata  reserved - to be defined in a future version of MATLAB
  748. % handles    structure with handles and user data (see GUIDATA)
  749.  
  750. % Hints: get(hObject,'String') returns contents of edit4 as text
  751. %        str2double(get(hObject,'String')) returns contents of edit4 as a double
  752.  
  753.  
  754. % --- Executes during object creation, after setting all properties.
  755. function edit4_CreateFcn(hObject, eventdata, handles)
  756. % hObject    handle to edit4 (see GCBO)
  757. % eventdata  reserved - to be defined in a future version of MATLAB
  758. % handles    empty - handles not created until after all CreateFcns called
  759.  
  760. % Hint: edit controls usually have a white background on Windows.
  761. %       See ISPC and COMPUTER.
  762. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  763.     set(hObject,'BackgroundColor','white');
  764. end
  765.  
  766.  
  767.  
  768. function edit5_Callback(hObject, eventdata, handles)
  769. % hObject    handle to edit5 (see GCBO)
  770. % eventdata  reserved - to be defined in a future version of MATLAB
  771. % handles    structure with handles and user data (see GUIDATA)
  772.  
  773. % Hints: get(hObject,'String') returns contents of edit5 as text
  774. %        str2double(get(hObject,'String')) returns contents of edit5 as a double
  775.  
  776.  
  777. % --- Executes during object creation, after setting all properties.
  778. function edit5_CreateFcn(hObject, eventdata, handles)
  779. % hObject    handle to edit5 (see GCBO)
  780. % eventdata  reserved - to be defined in a future version of MATLAB
  781. % handles    empty - handles not created until after all CreateFcns called
  782.  
  783. % Hint: edit controls usually have a white background on Windows.
  784. %       See ISPC and COMPUTER.
  785. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  786.     set(hObject,'BackgroundColor','white');
  787. end
  788.  
  789.  
  790. % --- Executes during object creation, after setting all properties.
  791. function axes6_CreateFcn(hObject, eventdata, handles)
  792. % hObject    handle to axes6 (see GCBO)
  793. % eventdata  reserved - to be defined in a future version of MATLAB
  794. % handles    empty - handles not created until after all CreateFcns called
  795.  
  796. % Hint: place code in OpeningFcn to populate axes6
  797.  
  798.  
  799. % --- Executes on button press in btnConfirmMode.
  800. function btnConfirmMode_Callback(hObject, eventdata, handles)
  801. % hObject    handle to btnConfirmMode (see GCBO)
  802. % eventdata  reserved - to be defined in a future version of MATLAB
  803. % handles    structure with handles and user data (see GUIDATA)
  804. modeSelectedObj = get(handles.modeSelection,'SelectedObject')
  805. modeSelectedLabel = get(modeSelectedObj,'String')
  806.  
  807.  
  808. if (strcmp(modeSelectedLabel,'Single Mode') == 1)
  809.     set(handles.btnChooseSample,'String','Choose File')
  810.     set(handles.modeLabelBig,'String', 'Single Mode')
  811.     set(handles.rghTypeLabel,'String', 'Surface roughness')
  812. elseif (strcmp(modeSelectedLabel,'Batch Mode') == 1)
  813.     set(handles.btnChooseSample,'String','Choose Folder')
  814.     set(handles.modeLabelBig,'String', 'Batch Mode')
  815.     set(handles.rghTypeLabel,'String', 'Area roughness')
  816. end
  817.  
  818. % --- Executes on button press in batchModeRadio.
  819. function batchModeRadio_Callback(hObject, eventdata, handles)
  820. % hObject    handle to batchModeRadio (see GCBO)
  821. % eventdata  reserved - to be defined in a future version of MATLAB
  822. % handles    structure with handles and user data (see GUIDATA)
  823.  
  824. % Hint: get(hObject,'Value') returns toggle state of batchModeRadio
  825.  
  826.  
  827. % --- Executes on button press in singleModeRadio.
  828. function singleModeRadio_Callback(hObject, eventdata, handles)
  829. % hObject    handle to singleModeRadio (see GCBO)
  830. % eventdata  reserved - to be defined in a future version of MATLAB
  831. % handles    structure with handles and user data (see GUIDATA)
  832.  
  833. % Hint: get(hObject,'Value') returns toggle state of singleModeRadio
  834.  
  835.  
  836. % --- Executes on button press in pushbutton10.
  837. function pushbutton10_Callback(hObject, eventdata, handles)
  838. % hObject    handle to pushbutton10 (see GCBO)
  839. % eventdata  reserved - to be defined in a future version of MATLAB
  840. % handles    structure with handles and user data (see GUIDATA)
  841.  
  842.  
  843. % --- Executes on button press in pushbutton11.
  844. function pushbutton11_Callback(hObject, eventdata, handles)
  845. % hObject    handle to pushbutton11 (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.  
  850. % --- Executes on button press in pushbutton13.
  851. function pushbutton13_Callback(hObject, eventdata, handles)
  852. % hObject    handle to pushbutton13 (see GCBO)
  853. % eventdata  reserved - to be defined in a future version of MATLAB
  854. % handles    structure with handles and user data (see GUIDATA)
  855.  
  856.  
  857. % --- Executes on button press in pushbutton14.
  858. function pushbutton14_Callback(hObject, eventdata, handles)
  859. % hObject    handle to pushbutton14 (see GCBO)
  860. % eventdata  reserved - to be defined in a future version of MATLAB
  861. % handles    structure with handles and user data (see GUIDATA)
  862.  
  863.  
  864. % --- Executes on selection change in popupmenu3.
  865. function popupmenu3_Callback(hObject, eventdata, handles)
  866. % hObject    handle to popupmenu3 (see GCBO)
  867. % eventdata  reserved - to be defined in a future version of MATLAB
  868. % handles    structure with handles and user data (see GUIDATA)
  869.  
  870. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
  871. %        contents{get(hObject,'Value')} returns selected item from popupmenu3
  872.  
  873.  
  874. % --- Executes during object creation, after setting all properties.
  875. function popupmenu3_CreateFcn(hObject, eventdata, handles)
  876. % hObject    handle to popupmenu3 (see GCBO)
  877. % eventdata  reserved - to be defined in a future version of MATLAB
  878. % handles    empty - handles not created until after all CreateFcns called
  879.  
  880. % Hint: popupmenu controls usually have a white background on Windows.
  881. %       See ISPC and COMPUTER.
  882. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  883.     set(hObject,'BackgroundColor','white');
  884. end
  885.  
  886.  
  887. % --- Executes on selection change in popupmenu4.
  888. function popupmenu4_Callback(hObject, eventdata, handles)
  889. % hObject    handle to popupmenu4 (see GCBO)
  890. % eventdata  reserved - to be defined in a future version of MATLAB
  891. % handles    structure with handles and user data (see GUIDATA)
  892.  
  893. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
  894. %        contents{get(hObject,'Value')} returns selected item from popupmenu4
  895.  
  896.  
  897. % --- Executes during object creation, after setting all properties.
  898. function popupmenu4_CreateFcn(hObject, eventdata, handles)
  899. % hObject    handle to popupmenu4 (see GCBO)
  900. % eventdata  reserved - to be defined in a future version of MATLAB
  901. % handles    empty - handles not created until after all CreateFcns called
  902.  
  903. % Hint: popupmenu controls usually have a white background on Windows.
  904. %       See ISPC and COMPUTER.
  905. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  906.     set(hObject,'BackgroundColor','white');
  907. end
  908.  
  909.  
  910. % --- Executes on selection change in popupmenu5.
  911. function popupmenu5_Callback(hObject, eventdata, handles)
  912. % hObject    handle to popupmenu5 (see GCBO)
  913. % eventdata  reserved - to be defined in a future version of MATLAB
  914. % handles    structure with handles and user data (see GUIDATA)
  915.  
  916. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu5 contents as cell array
  917. %        contents{get(hObject,'Value')} returns selected item from popupmenu5
  918.  
  919.  
  920. % --- Executes during object creation, after setting all properties.
  921. function popupmenu5_CreateFcn(hObject, eventdata, handles)
  922. % hObject    handle to popupmenu5 (see GCBO)
  923. % eventdata  reserved - to be defined in a future version of MATLAB
  924. % handles    empty - handles not created until after all CreateFcns called
  925.  
  926. % Hint: popupmenu controls usually have a white background on Windows.
  927. %       See ISPC and COMPUTER.
  928. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  929.     set(hObject,'BackgroundColor','white');
  930. end
  931.  
  932.  
  933. % --- Executes on selection change in popupmenu6.
  934. function popupmenu6_Callback(hObject, eventdata, handles)
  935. % hObject    handle to popupmenu6 (see GCBO)
  936. % eventdata  reserved - to be defined in a future version of MATLAB
  937. % handles    structure with handles and user data (see GUIDATA)
  938.  
  939. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu6 contents as cell array
  940. %        contents{get(hObject,'Value')} returns selected item from popupmenu6
  941.  
  942.  
  943. % --- Executes during object creation, after setting all properties.
  944. function popupmenu6_CreateFcn(hObject, eventdata, handles)
  945. % hObject    handle to popupmenu6 (see GCBO)
  946. % eventdata  reserved - to be defined in a future version of MATLAB
  947. % handles    empty - handles not created until after all CreateFcns called
  948.  
  949. % Hint: popupmenu controls usually have a white background on Windows.
  950. %       See ISPC and COMPUTER.
  951. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  952.     set(hObject,'BackgroundColor','white');
  953. end
  954.  
  955.  
  956. % --- Executes on selection change in listbox1.
  957. function listbox1_Callback(hObject, eventdata, handles)
  958. % hObject    handle to listbox1 (see GCBO)
  959. % eventdata  reserved - to be defined in a future version of MATLAB
  960. % handles    structure with handles and user data (see GUIDATA)
  961.  
  962. % Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
  963. %        contents{get(hObject,'Value')} returns selected item from listbox1
  964.  
  965.  
  966. % --- Executes during object creation, after setting all properties.
  967. function listbox1_CreateFcn(hObject, eventdata, handles)
  968. % hObject    handle to listbox1 (see GCBO)
  969. % eventdata  reserved - to be defined in a future version of MATLAB
  970. % handles    empty - handles not created until after all CreateFcns called
  971.  
  972. % Hint: listbox controls usually have a white background on Windows.
  973. %       See ISPC and COMPUTER.
  974. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  975.     set(hObject,'BackgroundColor','white');
  976. end
Advertisement
Add Comment
Please, Sign In to add comment