| 1 | %'set_grid':produce grid for PIV with one or two images (stereo case) |
|---|
| 2 | %------------------------------------------------------------------------ |
|---|
| 3 | % function varargout = set_grid(varargin) |
|---|
| 4 | % associated with the GUI set_grid.fig |
|---|
| 5 | % |
|---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
|---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 9 | % This file is part of the toolbox UVMAT. |
|---|
| 10 | % |
|---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
|---|
| 12 | % it under the terms of the GNU General Public License as published by |
|---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
|---|
| 14 | % (at your option) any later version. |
|---|
| 15 | % |
|---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
|---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
|---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 21 | |
|---|
| 22 | function varargout = set_grid(varargin) |
|---|
| 23 | |
|---|
| 24 | % Last Modified by GUIDE v2.5 04-Feb-2008 16:05:02 |
|---|
| 25 | |
|---|
| 26 | % Begin initialization code - DO NOT EDIT |
|---|
| 27 | gui_Singleton = 1; |
|---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
|---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
|---|
| 30 | 'gui_OpeningFcn', @set_grid_OpeningFcn, ... |
|---|
| 31 | 'gui_OutputFcn', @set_grid_OutputFcn, ... |
|---|
| 32 | 'gui_LayoutFcn', [] , ... |
|---|
| 33 | 'gui_Callback', []); |
|---|
| 34 | if nargin & isstr(varargin{1}) |
|---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
|---|
| 36 | end |
|---|
| 37 | |
|---|
| 38 | if nargout |
|---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
|---|
| 40 | else |
|---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
|---|
| 42 | end |
|---|
| 43 | % End initialization code - DO NOT EDIT |
|---|
| 44 | |
|---|
| 45 | %------------------------------------------------------------------- |
|---|
| 46 | % --- Executes just before set_grid is made visible. |
|---|
| 47 | %INPUT: |
|---|
| 48 | % handles: handles of the set_grid interface elements |
|---|
| 49 | %'IndexObj': index of the object (on the UvData list) that set_grid will modify |
|---|
| 50 | % if =[] or absent: index still undefined (create mode in uvmat) |
|---|
| 51 | % if=0; no associated object (used for series), the button 'PLOT' is then unvisible |
|---|
| 52 | %'data': read from an existing object selected in the interface |
|---|
| 53 | % .TITLE : class of object ('POINTS','LINE',....) |
|---|
| 54 | % .DX,DY,DZ; meshes for regular grids |
|---|
| 55 | % .Coord: object position coordinates |
|---|
| 56 | % .ParentButton: handle of the uicontrol object calling the interface |
|---|
| 57 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
|---|
| 58 | % if =[] or absent, no plot (mask mode in uvmat) |
|---|
| 59 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
|---|
| 60 | function set_grid_OpeningFcn(hObject, eventdata, handles,inputfile) |
|---|
| 61 | |
|---|
| 62 | % Choose default command line output for set_grid |
|---|
| 63 | handles.output = hObject; |
|---|
| 64 | |
|---|
| 65 | % Update handles structure |
|---|
| 66 | guidata(hObject, handles); |
|---|
| 67 | |
|---|
| 68 | %default |
|---|
| 69 | % set(hObject,'Unit','Normalized')% set the unit normalized to the screen size |
|---|
| 70 | % set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the set_grid interface |
|---|
| 71 | set(hObject,'DeleteFcn',@closefcn) |
|---|
| 72 | set(handles.TITLE,'Value',1) |
|---|
| 73 | set(handles.ObjectStyle,'Value',1) |
|---|
| 74 | set(handles.ProjMode,'Value',1) |
|---|
| 75 | set(handles.MenuCoord,'ListboxTop',1) |
|---|
| 76 | set(handles.MenuCoord,'Value',1); |
|---|
| 77 | set(handles.MenuCoord,'String',{'phys';'px'}); |
|---|
| 78 | if exist('inputfile','var')& ~isempty(inputfile) |
|---|
| 79 | set(handles.image_1,'String',inputfile) |
|---|
| 80 | set(handles.image_2,'String',inputfile) |
|---|
| 81 | end |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | % --- Outputs from this function are returned to the command line. |
|---|
| 85 | function varargout = set_grid_OutputFcn(hObject, eventdata, handles) |
|---|
| 86 | % varargout cell array for returning output args (see VARARGOUT); |
|---|
| 87 | % hObject handle to figure |
|---|
| 88 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 89 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 90 | |
|---|
| 91 | % Get default command line output from handles structure |
|---|
| 92 | varargout{1} = handles.output; |
|---|
| 93 | varargout{2}=handles; |
|---|
| 94 | |
|---|
| 95 | % --- Executes on selection change in ObjectStyle. |
|---|
| 96 | function ObjectStyle_Callback(hObject, eventdata, handles) |
|---|
| 97 | |
|---|
| 98 | ProjMode_Callback(hObject, eventdata, handles) |
|---|
| 99 | |
|---|
| 100 | %---------------------------------------------- |
|---|
| 101 | function xObject_Callback(hObject, eventdata, handles) |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | function yObject_Callback(hObject, eventdata, handles) |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | % --- Executes on selection change in zObject. |
|---|
| 108 | function zObject_Callback(hObject, eventdata, handles) |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | %--------------------------------------------------- |
|---|
| 112 | % --- Executes on selection change in ProjMode. |
|---|
| 113 | function ProjMode_Callback(hObject, eventdata, handles) |
|---|
| 114 | menu=get(handles.ProjMode,'String'); |
|---|
| 115 | value=get(handles.ProjMode,'Value'); |
|---|
| 116 | ProjMode=menu{value}; |
|---|
| 117 | menu=get(handles.ObjectStyle,'String'); |
|---|
| 118 | value=get(handles.ObjectStyle,'Value'); |
|---|
| 119 | ObjectStyle=menu{value}; |
|---|
| 120 | test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case |
|---|
| 121 | if isequal(ObjectStyle,'plane')||isequal(ObjectStyle,'volume') |
|---|
| 122 | set(handles.Phi,'Visible','on') |
|---|
| 123 | if test3D%3D case |
|---|
| 124 | set(handles.Theta,'Visible','on') |
|---|
| 125 | set(handles.Psi,'Visible','on') |
|---|
| 126 | end |
|---|
| 127 | set(handles.XMin,'Visible','on') |
|---|
| 128 | set(handles.XMax,'Visible','on') |
|---|
| 129 | set(handles.YMin,'Visible','on') |
|---|
| 130 | set(handles.YMax,'Visible','on') |
|---|
| 131 | if test3D |
|---|
| 132 | set(handles.Theta,'Visible','on') |
|---|
| 133 | set(handles.Psi,'Visible','on') |
|---|
| 134 | set(handles.ZMin,'Visible','on') |
|---|
| 135 | set(handles.ZMax,'Visible','on') |
|---|
| 136 | end |
|---|
| 137 | else |
|---|
| 138 | set(handles.Phi,'Visible','off') |
|---|
| 139 | set(handles.Theta,'Visible','off') |
|---|
| 140 | set(handles.Psi,'Visible','off') |
|---|
| 141 | set(handles.XMin,'Visible','off') |
|---|
| 142 | set(handles.XMax,'Visible','off') |
|---|
| 143 | set(handles.YMin,'Visible','off') |
|---|
| 144 | if isequal(ProjMode,'interp') |
|---|
| 145 | set(handles.YMax,'Visible','off') |
|---|
| 146 | else |
|---|
| 147 | set(handles.YMax,'Visible','on') |
|---|
| 148 | end |
|---|
| 149 | if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse') |
|---|
| 150 | set(handles.XMax,'Visible','on') |
|---|
| 151 | else |
|---|
| 152 | set(handles.XMax,'Visible','off') |
|---|
| 153 | end |
|---|
| 154 | set(handles.ZMin,'Visible','off') |
|---|
| 155 | set(handles.ZMax,'Visible','off') |
|---|
| 156 | end |
|---|
| 157 | if isequal(ProjMode,'projection')|isequal(ProjMode,'inside')|isequal(ProjMode,'outside')|isequal(ObjectStyle,'points') |
|---|
| 158 | set(handles.DX,'Visible','off') |
|---|
| 159 | set(handles.DY,'Visible','off') |
|---|
| 160 | set(handles.DZ,'Visible','off') |
|---|
| 161 | else |
|---|
| 162 | set(handles.DX,'Visible','on') |
|---|
| 163 | set(handles.DY,'Visible','on') |
|---|
| 164 | if test3D%3D case |
|---|
| 165 | set(handles.DZ,'Visible','on') |
|---|
| 166 | end |
|---|
| 167 | end |
|---|
| 168 | |
|---|
| 169 | %--------------------------------------------- |
|---|
| 170 | % --- Executes on selection change in TITLE. |
|---|
| 171 | function TITLE_Callback(hObject, eventdata, handles) |
|---|
| 172 | hsetobject=get(handles.TITLE,'parent'); |
|---|
| 173 | SetData=get(hsetobject,'UserData');%get the hidden interface data |
|---|
| 174 | % function named CALLBACK in UNTITLED.M with the given input arguments. |
|---|
| 175 | menu=get(handles.TITLE,'String'); |
|---|
| 176 | value=get(handles.TITLE,'Value'); |
|---|
| 177 | titl=menu{value}; |
|---|
| 178 | if isequal(titl,'POINTS') |
|---|
| 179 | menu_style={'points'}; |
|---|
| 180 | menu_proj={'projection';'interp';'filter';'none'}; |
|---|
| 181 | elseif isequal(titl,'LINE') |
|---|
| 182 | menu_style={'line';'polyline';'rectangle';'polygon';'ellipse'};%'line' =default |
|---|
| 183 | menu_proj={'projection';'interp';'filter';'none'}; |
|---|
| 184 | elseif isequal(titl,'PATCH') |
|---|
| 185 | menu_style={'rectangle';'polygon';'ellipse'};%'line' =default |
|---|
| 186 | menu_proj={'inside';'outside';'none'}; |
|---|
| 187 | elseif isequal(titl,'PLANE') |
|---|
| 188 | menu_style={'plane'}; |
|---|
| 189 | menu_proj={'projection';'interp'}; |
|---|
| 190 | elseif isequal(titl,'VOLUME') |
|---|
| 191 | menu_style={'volume'}; |
|---|
| 192 | menu_proj={'none'}; |
|---|
| 193 | |
|---|
| 194 | end |
|---|
| 195 | set(handles.ObjectStyle,'String',menu_style) |
|---|
| 196 | set(handles.ObjectStyle,'Value',1) |
|---|
| 197 | set(handles.ProjMode,'String',menu_proj) |
|---|
| 198 | set(handles.ProjMode,'Value',1) |
|---|
| 199 | if isfield(SetData,'ParentButton') |
|---|
| 200 | update_parentbutton(SetData.ParentButton,titl) |
|---|
| 201 | end |
|---|
| 202 | ObjectStyle_Callback(hObject, eventdata, handles) |
|---|
| 203 | |
|---|
| 204 | %----------- |
|---|
| 205 | function update_parentbutton(ParentButton,titl) |
|---|
| 206 | |
|---|
| 207 | if isstruct(ParentButton) |
|---|
| 208 | parentfields=fields(ParentButton); |
|---|
| 209 | for ibutton=1:length(parentfields) |
|---|
| 210 | buttonhandle=eval(['ParentButton.' parentfields{ibutton}]); |
|---|
| 211 | if ishandle(buttonhandle) |
|---|
| 212 | set(buttonhandle,'Value',0) |
|---|
| 213 | set(buttonhandle,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 214 | end |
|---|
| 215 | end |
|---|
| 216 | if isfield(ParentButton,titl) |
|---|
| 217 | buttonhandle=eval(['ParentButton.' titl]); |
|---|
| 218 | if ishandle(buttonhandle) |
|---|
| 219 | set(buttonhandle,'Value',1) |
|---|
| 220 | set(buttonhandle,'BackgroundColor',[1 1 0])%put activated button to yellow |
|---|
| 221 | end |
|---|
| 222 | end |
|---|
| 223 | end |
|---|
| 224 | %------------ |
|---|
| 225 | function Phi_Callback(hObject, eventdata, handles) |
|---|
| 226 | update_slider(hObject, eventdata,handles) |
|---|
| 227 | |
|---|
| 228 | function Theta_Callback(hObject, eventdata, handles) |
|---|
| 229 | update_slider(hObject, eventdata,handles) |
|---|
| 230 | |
|---|
| 231 | function update_slider(hObject, eventdata,handles) |
|---|
| 232 | %rotation angles |
|---|
| 233 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
|---|
| 234 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
|---|
| 235 | |
|---|
| 236 | %components of the unitiy vector normal to the projection plane |
|---|
| 237 | NormVec_X=-sin(Phi)*sin(Theta); |
|---|
| 238 | NormVec_Y=cos(Phi)*sin(Theta); |
|---|
| 239 | NormVec_Z=cos(Theta); |
|---|
| 240 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
|---|
| 241 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
|---|
| 242 | Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z); |
|---|
| 243 | set(handles.z_slider,'Min',min(Z)) |
|---|
| 244 | set(handles.z_slider,'Max',max(Z)) |
|---|
| 245 | ZMax_Callback(hObject, eventdata, handles) |
|---|
| 246 | |
|---|
| 247 | function DX_Callback(hObject, eventdata, handles) |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | function DY_Callback(hObject, eventdata, handles) |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | function DZ_Callback(hObject, eventdata, handles) |
|---|
| 254 | |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | %----------------------------------------------------- |
|---|
| 258 | % --- Executes on button press in import. |
|---|
| 259 | function import_Callback(hObject, eventdata, handles) |
|---|
| 260 | %get the object file |
|---|
| 261 | oldfile=''; |
|---|
| 262 | huvmat=findobj('Tag','uvmat'); |
|---|
| 263 | if isempty(huvmat) |
|---|
| 264 | huvmat=findobj(allchild(0),'Name','series'); |
|---|
| 265 | end |
|---|
| 266 | hchild=get(huvmat,'Children'); |
|---|
| 267 | hrootpath=findobj(hchild,'Tag','RootPath'); |
|---|
| 268 | oldfile=get(hrootpath,'String'); |
|---|
| 269 | if iscell(oldfile) |
|---|
| 270 | oldfile=oldfile{1}; |
|---|
| 271 | end |
|---|
| 272 | %[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile) |
|---|
| 273 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 274 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
|---|
| 275 | '*.xml', '.xml files '; ... |
|---|
| 276 | '*.mat', '.mat matlab files '}, ... |
|---|
| 277 | 'Pick a file',oldfile); |
|---|
| 278 | fileinput=[PathName FileName];%complete file name |
|---|
| 279 | testblank=findstr(fileinput,' ');%look for blanks |
|---|
| 280 | if ~isempty(testblank) |
|---|
| 281 | errordlg('forbidden input file name: contain blanks') |
|---|
| 282 | return |
|---|
| 283 | end |
|---|
| 284 | sizf=size(fileinput); |
|---|
| 285 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
|---|
| 286 | |
|---|
| 287 | %read the file |
|---|
| 288 | t=xmltree(fileinput); |
|---|
| 289 | s=convert(t); |
|---|
| 290 | testmode=0; |
|---|
| 291 | if isfield(s,'ProjMode') |
|---|
| 292 | menu=get(handles.ProjMode,'String'); |
|---|
| 293 | for iline=1:length(menu) |
|---|
| 294 | if isequal(menu{iline},s.ProjMode) |
|---|
| 295 | set(handles.ProjMode,'Value',iline) |
|---|
| 296 | testmode=1; |
|---|
| 297 | break |
|---|
| 298 | end |
|---|
| 299 | end |
|---|
| 300 | end |
|---|
| 301 | |
|---|
| 302 | ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes |
|---|
| 303 | if isfield(s,'CoordType') |
|---|
| 304 | if isequal(s.CoordType,'phys') |
|---|
| 305 | set(handles.MenuCoord,'Value',1) |
|---|
| 306 | elseif isequal(s.CoordType,'px') |
|---|
| 307 | set(handles.MenuCoord,'Value',2) |
|---|
| 308 | else |
|---|
| 309 | warndlg('unknown CoordType (px or phys) in set_grid.m') |
|---|
| 310 | end |
|---|
| 311 | end |
|---|
| 312 | if isfield(s,'XMax') |
|---|
| 313 | set(handles.XMax,'String',s.XMax) |
|---|
| 314 | end |
|---|
| 315 | if isfield(s,'XMin') |
|---|
| 316 | set(handles.XMin,'String',s.XMin) |
|---|
| 317 | end |
|---|
| 318 | if isfield(s,'YMax') |
|---|
| 319 | set(handles.YMax,'String',s.YMax) |
|---|
| 320 | end |
|---|
| 321 | if isfield(s,'YMin') |
|---|
| 322 | set(handles.YMin,'String',s.YMin) |
|---|
| 323 | end |
|---|
| 324 | if isfield(s,'DX') |
|---|
| 325 | set(handles.DX,'String',s.DX) |
|---|
| 326 | end |
|---|
| 327 | if isfield(s,'DY') |
|---|
| 328 | set(handles.DY,'String',s.DY) |
|---|
| 329 | end |
|---|
| 330 | if ~isfield(s,'Coord') |
|---|
| 331 | XObject='0';%default |
|---|
| 332 | YObject='0'; |
|---|
| 333 | elseif ischar(s.Coord) |
|---|
| 334 | line=str2num(s.Coord); |
|---|
| 335 | XObject=num2str(line(1)); |
|---|
| 336 | YObject=num2str(line(2)); |
|---|
| 337 | else |
|---|
| 338 | for i=1:length(s.Coord) |
|---|
| 339 | line=str2num(s.Coord{i}); |
|---|
| 340 | XObject{i}=num2str(line(1)); |
|---|
| 341 | YObject{i}=num2str(line(2)); |
|---|
| 342 | end |
|---|
| 343 | end |
|---|
| 344 | set(handles.XObject,'String',XObject) |
|---|
| 345 | set(handles.YObject,'String',YObject) |
|---|
| 346 | %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_grid_Opening |
|---|
| 347 | |
|---|
| 348 | %---------------------------------------------------- |
|---|
| 349 | % executed when closing: set the parent interface button to value 0 |
|---|
| 350 | function closefcn(gcbo,eventdata) |
|---|
| 351 | huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle |
|---|
| 352 | parent_button=findobj(huvmat,'Tag','grid'); |
|---|
| 353 | if ~isempty(parent_button) |
|---|
| 354 | set(parent_button,'Value',0)%put unactivated buttons to green |
|---|
| 355 | tag=get(parent_button,'Tag'); |
|---|
| 356 | if isequal(tag,'edit') |
|---|
| 357 | set(parent_button,'BackgroundColor',[0.7 0.7 0.7]); |
|---|
| 358 | else |
|---|
| 359 | set(parent_button,'BackgroundColor',[0 1 0]); |
|---|
| 360 | end |
|---|
| 361 | end |
|---|
| 362 | |
|---|
| 363 | %----------------------------------------------------------------------- |
|---|
| 364 | % --- Executes on button press in edit: PLOT the defined object and its projected field |
|---|
| 365 | function edit_Callback(hObject, eventdata, handles) |
|---|
| 366 | hsetobject=get(hObject,'parent'); |
|---|
| 367 | SetData=get(hsetobject,'UserData');%get the hidden interface data |
|---|
| 368 | %IndexObj=SetData.IndexObj%index of the current projection object in the list of projection objects (UvData.ProjObject) |
|---|
| 369 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
|---|
| 370 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
|---|
| 371 | if isfield(UvData,'CuurentObjectIndex') |
|---|
| 372 | IndexObj=UvData.CurrentObjectIndex; |
|---|
| 373 | else |
|---|
| 374 | IndexObj=[]; |
|---|
| 375 | end |
|---|
| 376 | ObjectData=read_set_grid(handles);%read the interface input parameters defining the object |
|---|
| 377 | [UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles); |
|---|
| 378 | uvmat('write_plot_param',PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object |
|---|
| 379 | SetData.IndexObj=IndexObj; |
|---|
| 380 | set(gcbf,'UserData',SetData)%update object index in the set_grid interface |
|---|
| 381 | set(huvmat,'UserData',UvData)%update the data in the uvmat interface |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | % --- Executes on button press in MenuCoord. |
|---|
| 385 | function MenuCoord_Callback(hObject, eventdata, handles) |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 389 | % --- Executes on button press in delete. |
|---|
| 390 | function delete_Callback(hObject, eventdata, handles) |
|---|
| 391 | |
|---|
| 392 | %SetData=get(gcbf,'UserData');%get the interface data |
|---|
| 393 | %IndexObj=SetData.IndexObj; |
|---|
| 394 | huvmat=findobj('Name','uvmat');%find the current uvmat interface handle |
|---|
| 395 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
|---|
| 396 | if isfield(UvData,'CurrentObjectIndex') |
|---|
| 397 | IndexObj=UvData.CurrentObjectIndex; |
|---|
| 398 | else |
|---|
| 399 | IndexObj=[]; |
|---|
| 400 | end |
|---|
| 401 | delete_object(IndexObj); |
|---|
| 402 | |
|---|
| 403 | %---------------------------------------------------- |
|---|
| 404 | function YMin_Callback(hObject, eventdata, handles) |
|---|
| 405 | % hObject handle to YMin (see GCBO) |
|---|
| 406 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 407 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 408 | |
|---|
| 409 | % Hints: get(hObject,'String') returns contents of YMin as text |
|---|
| 410 | % str2double(get(hObject,'String')) returns contents of YMin as a double |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | function ZMin_Callback(hObject, eventdata, handles) |
|---|
| 414 | |
|---|
| 415 | |
|---|
| 416 | function ZMax_Callback(hObject, eventdata, handles) |
|---|
| 417 | DZ=str2num(get(handles.ZMax,'String')); |
|---|
| 418 | ZMin=get(handles.z_slider,'Min'); |
|---|
| 419 | ZMax=get(handles.z_slider,'Max'); |
|---|
| 420 | rel_step(1)=DZ/(ZMax-ZMin); |
|---|
| 421 | rel_step(2)=0.2; |
|---|
| 422 | set(handles.z_slider,'SliderStep',rel_step) |
|---|
| 423 | |
|---|
| 424 | function YMax_Callback(hObject, eventdata, handles) |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | function XMin_Callback(hObject, eventdata, handles) |
|---|
| 428 | |
|---|
| 429 | |
|---|
| 430 | function XMax_Callback(hObject, eventdata, handles) |
|---|
| 431 | |
|---|
| 432 | |
|---|
| 433 | % ------------------------------------------------------ |
|---|
| 434 | function save_Callback(hObject, eventdata, handles) |
|---|
| 435 | % ------------------------------------------------------ |
|---|
| 436 | Object=read_set_object(handles);%read the set_grid interface; |
|---|
| 437 | DX=Object.DX; |
|---|
| 438 | DY=Object.DY; |
|---|
| 439 | RangeX=Object.RangeX; |
|---|
| 440 | RangeY=Object.RangeY; |
|---|
| 441 | array_realx=[RangeX(2):DX:RangeX(1)]; |
|---|
| 442 | array_realy=[RangeY(2):DY:RangeY(1)]; |
|---|
| 443 | nx_patch=length(array_realx); |
|---|
| 444 | ny_patch=length(array_realy); |
|---|
| 445 | [grid_realx,grid_realy]=meshgrid(array_realx,array_realy); |
|---|
| 446 | grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1); |
|---|
| 447 | grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1); |
|---|
| 448 | grid_real(:,3)=zeros(nx_patch*ny_patch,1); |
|---|
| 449 | |
|---|
| 450 | imageA=get(handles.image_1,'String'); |
|---|
| 451 | imageB=get(handles.image_2,'String'); |
|---|
| 452 | testB=1; |
|---|
| 453 | if isempty(imageA) || isequal(imageA,'') |
|---|
| 454 | if isempty(imageB) || isequal(imageB,'') |
|---|
| 455 | msgbox_uvmat('ERROR','at least one image file name must be introduced') |
|---|
| 456 | else |
|---|
| 457 | imageA=imageB; |
|---|
| 458 | testB=0; |
|---|
| 459 | end |
|---|
| 460 | end |
|---|
| 461 | if isempty(imageB) || isequal(imageB,'') || isequal(imageA,imageB) |
|---|
| 462 | testB=0; |
|---|
| 463 | end |
|---|
| 464 | |
|---|
| 465 | testexist=exist(imageA,'file'); |
|---|
| 466 | if isequal(testexist,0) |
|---|
| 467 | msgbox_uvmat('ERROR',['input image file' imageA 'does not exist']) |
|---|
| 468 | return |
|---|
| 469 | end |
|---|
| 470 | [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageA); |
|---|
| 471 | form=imformats(ext(2:end)); |
|---|
| 472 | if isempty(form)% if the extension corresponds to an image format recognized by Matlab |
|---|
| 473 | msgbox_uvmat('ERROR',['error: ' imageA ' is not an image name recognized by Matlab ']) |
|---|
| 474 | return |
|---|
| 475 | end |
|---|
| 476 | fileAxml=[fullfile(Pathsub,RootFile) '.xml']; |
|---|
| 477 | [XmlDataA,error]=imadoc2struct(fileAxml); |
|---|
| 478 | if isfield(XmlDataA,'GeometryCalib') |
|---|
| 479 | tsaiA=XmlDataA.GeometryCalib; |
|---|
| 480 | else |
|---|
| 481 | msgbox_uvmat('WARNING','no geometric calibration available for image A') |
|---|
| 482 | tsaiA=[]; |
|---|
| 483 | end |
|---|
| 484 | [grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2),0); |
|---|
| 485 | A=imread(imageA); |
|---|
| 486 | siz=size(A); |
|---|
| 487 | npxA=siz(2); |
|---|
| 488 | npyA=siz(1); |
|---|
| 489 | |
|---|
| 490 | flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA; |
|---|
| 491 | |
|---|
| 492 | if testB |
|---|
| 493 | testexist=exist(imageB,'file'); |
|---|
| 494 | if isequal(testexist,0) |
|---|
| 495 | msgbox_uvmat('ERROR',['input image file' imageB 'does not exist']) |
|---|
| 496 | return |
|---|
| 497 | end |
|---|
| 498 | [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageB); |
|---|
| 499 | form=imformats(ext([2:end])); |
|---|
| 500 | if isempty(form)% if the extension corresponds to an image format recognized by Matlab |
|---|
| 501 | msgbox_uvmat('ERROR',['error: ' imageB ' is not an image name recognized by Matlab ']) |
|---|
| 502 | return |
|---|
| 503 | end |
|---|
| 504 | fileBxml=[fullfile(Pathsub,RootFile) '.xml']; |
|---|
| 505 | [XmlDataB,error]=imadoc2struct(fileBxml); |
|---|
| 506 | if isfield(XmlDataB,'GeometryCalib') |
|---|
| 507 | tsaiB=XmlDataB.GeometryCalib; |
|---|
| 508 | else |
|---|
| 509 | msgbox_uvmat('WARNING','no geometric calibration available for image B') |
|---|
| 510 | tsaiB=[]; |
|---|
| 511 | end |
|---|
| 512 | %[error,Heading,nom_type_read,ext_ima_read,time,TimeUnit,mode,NbSlice,... |
|---|
| 513 | % npxB,npyB,tsaiB]=read_imadoc(fileBxml,0); |
|---|
| 514 | [grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2),0); |
|---|
| 515 | % if isempty(npxB)|isempty(npyB) |
|---|
| 516 | B=imread(imageB); |
|---|
| 517 | siz=size(B); |
|---|
| 518 | npxB=siz(2); |
|---|
| 519 | npyB=siz(1); |
|---|
| 520 | % end |
|---|
| 521 | flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB; |
|---|
| 522 | end |
|---|
| 523 | if testB |
|---|
| 524 | ind_good=find(flagA==1&flagB==1); |
|---|
| 525 | XimaB=grid_imaB(ind_good,1); |
|---|
| 526 | YimaB=grid_imaB(ind_good,2); |
|---|
| 527 | else |
|---|
| 528 | ind_good=find(flagA==1); |
|---|
| 529 | end |
|---|
| 530 | XimaA=grid_imaA(ind_good,1); |
|---|
| 531 | YimaA=grid_imaA(ind_good,2); |
|---|
| 532 | |
|---|
| 533 | grid_real_x=grid_real(ind_good,1); |
|---|
| 534 | grid_real_y=grid_real(ind_good,2); |
|---|
| 535 | nx_patch_new=length(grid_real_x); |
|---|
| 536 | grid_real2(:,1)=grid_real_x; |
|---|
| 537 | grid_real2(:,2)=grid_real_y; |
|---|
| 538 | grid_real2(:,3)=zeros(nx_patch_new,1); |
|---|
| 539 | [grid_pix_A(:,1),grid_pix_A(:,2)]=px_XYZ(tsaiA,grid_real2(:,1),grid_real2(:,2)); |
|---|
| 540 | if testB |
|---|
| 541 | [grid_pix_B(:,1),grid_pix_B(:,2)]=px_XYZ(tsaiB,grid_real2(:,1),grid_real2(:,2)); |
|---|
| 542 | end |
|---|
| 543 | |
|---|
| 544 | %ECRIRE FICHIERS |
|---|
| 545 | nbpointsA=size(grid_pix_A); |
|---|
| 546 | XA=grid_pix_A(:,1); |
|---|
| 547 | YA=grid_pix_A(:,2); |
|---|
| 548 | unitcolumn=32*ones(size(XA)); |
|---|
| 549 | Xchar=num2str(XA); |
|---|
| 550 | blanc=char(unitcolumn); |
|---|
| 551 | Ychar=num2str(YA); |
|---|
| 552 | tete=['1 ' num2str(nbpointsA(1))]; |
|---|
| 553 | txt=[Xchar blanc Ychar]; |
|---|
| 554 | textgrid={tete;txt}; |
|---|
| 555 | textout=char(textgrid); |
|---|
| 556 | Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridA.grid')); |
|---|
| 557 | % Answer = inputdlg('grid file name (*.grid)',' ',1,{fullfile(Pathsub,'gridA.grid')},'on'); |
|---|
| 558 | dlmwrite(Answer,textout,''); |
|---|
| 559 | msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); |
|---|
| 560 | if testB |
|---|
| 561 | nbpointsB=size(grid_pix_B); |
|---|
| 562 | XB=grid_pix_B(:,1); |
|---|
| 563 | YB=grid_pix_B(:,2); |
|---|
| 564 | unitcolumn=32*ones(size(XB)); |
|---|
| 565 | Xchar=num2str(XB); |
|---|
| 566 | blanc=char(unitcolumn); |
|---|
| 567 | Ychar=num2str(YB); |
|---|
| 568 | tete=['1 ' num2str(nbpointsB(1))]; |
|---|
| 569 | txt=[Xchar blanc Ychar]; |
|---|
| 570 | textgrid={tete;txt}; |
|---|
| 571 | textout=char(textgrid); |
|---|
| 572 | Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridB.grid')); |
|---|
| 573 | dlmwrite(Answer,textout,''); |
|---|
| 574 | msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); |
|---|
| 575 | end |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | % --- Executes on slider movement. |
|---|
| 579 | function z_slider_Callback(hObject, eventdata, handles) |
|---|
| 580 | %A ADAPTER |
|---|
| 581 | Z_value=get(handles.z_slider,'Value'); |
|---|
| 582 | |
|---|
| 583 | %rotation angles |
|---|
| 584 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
|---|
| 585 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
|---|
| 586 | |
|---|
| 587 | %components of the unity vector normal to the projection plane |
|---|
| 588 | NormVec_X=-sin(Phi)*sin(Theta); |
|---|
| 589 | NormVec_Y=cos(Phi)*sin(Theta); |
|---|
| 590 | NormVec_Z=cos(Theta); |
|---|
| 591 | |
|---|
| 592 | %set new plane position and update graph |
|---|
| 593 | set(handles.XObject,'String',num2str(NormVec_X*Z_value)) |
|---|
| 594 | set(handles.YObject,'String',num2str(NormVec_Y*Z_value)) |
|---|
| 595 | set(handles.ZObject,'String',num2str(NormVec_Z*Z_value)) |
|---|
| 596 | edit_Callback(hObject, eventdata, handles) |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | |
|---|
| 600 | function XObject_Callback(hObject, eventdata, handles) |
|---|
| 601 | |
|---|
| 602 | |
|---|
| 603 | function YObject_Callback(hObject, eventdata, handles) |
|---|
| 604 | |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | |
|---|
| 608 | function ZObject_Callback(hObject, eventdata, handles) |
|---|
| 609 | |
|---|
| 610 | |
|---|
| 611 | function image_2_Callback(hObject, eventdata, handles) |
|---|
| 612 | % hObject handle to image_2 (see GCBO) |
|---|
| 613 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 614 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 615 | |
|---|
| 616 | % Hints: get(hObject,'String') returns contents of image_2 as text |
|---|
| 617 | % str2double(get(hObject,'String')) returns contents of image_2 as a double |
|---|
| 618 | |
|---|
| 619 | |
|---|
| 620 | |
|---|
| 621 | function image_1_Callback(hObject, eventdata, handles) |
|---|
| 622 | % hObject handle to image_1 (see GCBO) |
|---|
| 623 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 624 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 625 | |
|---|
| 626 | % Hints: get(hObject,'String') returns contents of image_1 as text |
|---|
| 627 | % str2double(get(hObject,'String')) returns contents of image_1 as a double |
|---|
| 628 | |
|---|
| 629 | |
|---|
| 630 | % --- Executes on button press in HELP. |
|---|
| 631 | function HELP_Callback(hObject, eventdata, handles) |
|---|
| 632 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
|---|
| 633 | pathelp=fileparts(path_to_uvmat); |
|---|
| 634 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
|---|
| 635 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
|---|
| 636 | else |
|---|
| 637 | web([helpfile '#set_grid']) |
|---|
| 638 | end |
|---|
| 639 | |
|---|