Changeset 82 for trunk/src/uvmat.m
- Timestamp:
- Apr 15, 2010, 5:12:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r81 r82 3085 3085 3086 3086 %read the rootfile input display 3087 FileExt=get(handles.FileExt,'String');3087 [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); 3088 3088 [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]); 3089 3089 NomTypeNew=NomType;%default … … 3103 3103 elseif isequal(NomType,'_i1-i2') 3104 3104 NomTypeNew='_i'; 3105 % TODO: look for other types 3105 3106 end 3106 3107 end … … 3192 3193 RootPath_1=get(handles.RootPath_1,'String'); 3193 3194 RootFile_1=get(handles.RootFile_1,'String'); 3194 if isempty(RootPath_1)| isequal(RootPath_1,'')3195 if isempty(RootPath_1)||isequal(RootPath_1,'') 3195 3196 set(handles.RootPath_1,'String','"') 3196 3197 end 3197 if isempty(RootFile_1) | isequal(RootFile_1,'')3198 if isempty(RootFile_1) || isequal(RootFile_1,'') 3198 3199 set(handles.RootFile_1,'String','"') 3199 3200 end 3200 if ~isempty(RootFile_1)& (isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))3201 if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\')) 3201 3202 RootFile_1(1)=[]; 3202 3203 end … … 3249 3250 filebase_1=fullfile(RootPath_1,RootFile_1); 3250 3251 SubDir_1=get(handles.SubDir,'String'); 3251 if isempty(SubDir_1)| isequal(SubDir_1,'')3252 if isempty(SubDir_1)||isequal(SubDir_1,'') 3252 3253 if isfield(UvData,'SubDir_1') 3253 3254 SubDir_1=UvData.SubDir_1;%retrieve previous subdir … … 3256 3257 end 3257 3258 end 3258 if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2') 3259 str1=get(handles.i1,'String'); 3260 str_a=get(handles.j1,'String'); 3261 if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2') 3259 3262 NomTypeNew=NomType_1; 3260 3263 elseif isequal(NomType_1,'#a') 3261 [filename, idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);3264 [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1); 3262 3265 NomTypeNew='#_ab'; 3263 3266 elseif isequal(NomType_1,'_i_j') 3264 [filename, idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);3267 [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1); 3265 3268 if idetect==1 3266 3269 NomTypeNew='_i1-i2_j'; … … 3269 3272 end 3270 3273 else %for instance avi files or any ima_num series 3271 [filename, idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);3274 [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1); 3272 3275 NomTypeNew='_i1-i2'; 3273 3276 end … … 3587 3590 function save_mask_Callback(hObject, eventdata, handles) 3588 3591 %----------------------------------------------------------------------- 3589 huvmat=get(handles.save_mask,'parent'); 3590 UvData=get(huvmat,'UserData'); 3591 3592 hpatch=findobj(huvmat,'Type','patch'); 3592 UvData=get(handles.uvmat,'UserData'); 3593 3593 3594 flag=1; 3594 3595 npx=size(UvData.Field.A,2); … … 3616 3617 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 3617 3618 end 3618 flagobj=~inpolygon(Xi,Yi,X ,Y);%=0 inside the polygon, 1 outside3619 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside 3619 3620 elseif isequal(ObjectData.Style,'ellipse') 3620 3621 if testphys … … 4311 4312 hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface, 4312 4313 set(hset_object,'name',ObjectName) 4313 % pos_uvmat=get(handles.uvmat,'Position'); 4314 % %position the set_object GUI with respect to uvmat 4315 % if isfield(UvData,'SetObjectOrigin') 4316 % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); 4317 % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 4318 % set(hset_object,'Position',pos_set_object) 4314 4315 % %project the current field on the object and plot it 4316 % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData 4317 % if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes) 4318 % plot_field(ProjData,handles.axes3,PlotHandles); 4319 % UvData.Object{IndexObj}.plotaxes=handles.axes3; 4320 % else 4321 % UvData.Object{IndexObj}.plotaxes=view_field(ProjData); 4319 4322 % end 4320 4321 %project the current field on the object and plot it 4322 ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData 4323 if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes) 4324 plot_field(ProjData,handles.axes3,PlotHandles); 4325 UvData.Object{IndexObj}.plotaxes=handles.axes3; 4326 else 4327 UvData.Object{IndexObj}.plotaxes=view_field(ProjData); 4328 end 4329 set(handles.uvmat,'UserData',UvData) 4330 hother=findobj('Tag','proj_object');%find all the proj objects 4331 for iobj=1:length(hother) 4332 if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch') 4333 set(hother(iobj),'EdgeColor','b') 4334 if isequal(get(hother(iobj),'FaceColor'),'m') 4335 set(hother(iobj),'FaceColor','b') 4336 end 4337 elseif isequal(get(hother(iobj),'Type'),'image') 4338 Acolor=get(hother(iobj),'CData'); 4339 Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 4340 set(hother(iobj),'CData',Acolor); 4341 else 4342 set(hother(iobj),'Color','b') 4343 end 4344 set(hother(iobj),'Selected','off') 4345 end 4323 % set(handles.uvmat,'UserData',UvData) 4324 % hother=findobj('Tag','proj_object');%find all the proj objects 4325 % for iobj=1:length(hother) 4326 % if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch') 4327 % set(hother(iobj),'EdgeColor','b') 4328 % if isequal(get(hother(iobj),'FaceColor'),'m') 4329 % set(hother(iobj),'FaceColor','b') 4330 % end 4331 % elseif isequal(get(hother(iobj),'Type'),'image') 4332 % Acolor=get(hother(iobj),'CData'); 4333 % Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 4334 % set(hother(iobj),'CData',Acolor); 4335 % else 4336 % set(hother(iobj),'Color','b') 4337 % end 4338 % set(hother(iobj),'Selected','off') 4339 % end 4346 4340 hother=findobj('Tag','DeformPoint'); 4347 4341 set(hother,'Color','b'); … … 4390 4384 global CurData 4391 4385 CurData=get(handles.uvmat,'UserData'); 4392 % if isfield(UvData,'ProjField') 4393 CurData=UvData; 4394 evalin('base','global CurData')%make CurData global in the workspace 4395 display(['current field :']) 4396 % end 4386 evalin('base','global CurData')%make CurData global in the workspace 4387 display(['current field :']) 4397 4388 evalin('base','CurData') %display CurData in the workspace 4398 commandwindow; 4389 commandwindow; %brings the Matlab command window to the front 4399 4390 4400 4391 %------------------------------------------------------ … … 4547 4538 % ------------------------------------------------------------------ 4548 4539 function MenuMask_Callback(hObject, eventdata, handles) 4549 set(handles.TOOLS_txt,'Visible','on') 4550 set(handles.frame_tools,'Visible','on') 4551 % set(handles.create,'Visible','on') 4552 % set(handles.create,'Value',1) 4553 % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow 4554 set(handles.save_mask,'Visible','on') 4555 set(handles.masklevel,'Visible','on') 4556 if isequal(get(handles.z_index,'Visible'),'on') 4557 nb_slice=str2num(get(handles.nb_slice,'String')); 4558 for ilist=1:nb_slice 4559 list_index{ilist,1}=num2str(ilist); 4560 end 4561 set(handles.masklevel,'String',list_index) 4562 val=str2num(get(handles.z_index,'String')); 4563 if val<=nb_slice 4564 set(handles.masklevel,'Value',val) 4565 end 4566 else 4567 set(handles.masklevel,'String',{'1'}) 4568 set(handles.masklevel,'Value',1) 4569 end 4570 if ishandle(handles.UVMAT_title) 4571 delete(handles.UVMAT_title) 4572 end 4573 % huvmat=get(handles.create,'parent'); 4540 % set(handles.TOOLS_txt,'Visible','on') 4541 % set(handles.frame_tools,'Visible','on') 4542 % % set(handles.create,'Visible','on') 4543 % % set(handles.create,'Value',1) 4544 % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow 4545 % set(handles.save_mask,'Visible','on') 4546 % set(handles.masklevel,'Visible','on') 4547 % if isequal(get(handles.z_index,'Visible'),'on') 4548 % nb_slice=str2num(get(handles.nb_slice,'String')); 4549 % for ilist=1:nb_slice 4550 % list_index{ilist,1}=num2str(ilist); 4551 % end 4552 % set(handles.masklevel,'String',list_index) 4553 % val=str2num(get(handles.z_index,'String')); 4554 % if val<=nb_slice 4555 % set(handles.masklevel,'Value',val) 4556 % end 4557 % else 4558 % set(handles.masklevel,'String',{'1'}) 4559 % set(handles.masklevel,'Value',1) 4560 % end 4561 % if ishandle(handles.UVMAT_title) 4562 % delete(handles.UVMAT_title) 4563 % end 4574 4564 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4575 set(handles.zoom,'Value',0)4576 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])4577 set(handles.edit_vect,'Value',0)4578 edit_vect_Callback(hObject, eventdata, handles)4579 set(handles.edit,'Value',0)4580 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])4581 set(handles.edit_vect,'Value',0)4582 edit_vect_Callback(hObject, eventdata, handles)4565 % set(handles.zoom,'Value',0) 4566 % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7]) 4567 % set(handles.edit_vect,'Value',0) 4568 % edit_vect_Callback(hObject, eventdata, handles) 4569 % set(handles.edit,'Value',0) 4570 % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7]) 4571 % set(handles.edit_vect,'Value',0) 4572 % edit_vect_Callback(hObject, eventdata, handles) 4583 4573 % set(handles.cal,'Value',0) 4584 4574 % set(handles.cal,'BackgroundColor',[0 1 0]) 4585 4575 4586 4576 %initiate the GUI set_object 4587 data.TITLE='MASK'; 4588 if isfield(UvData,'CoordType') 4589 data.CoordType=UvData.CoordType; 4590 end 4591 if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4592 data.YMax=UvData.Mesh; 4593 elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image 4594 np=size(UvData.Field.A); 4595 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1); 4596 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1); 4597 data.YMax=max(meshx,meshy); 4598 data.DX=max(meshx,meshy); 4599 end 4600 data.Coord=[0 0 0]; %default 4601 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters 4602 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface 4603 pos_uvmat=get(handles.huvmat,'Position'); 4604 if isfield(UvData,'SetObjectOrigin') 4605 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); 4606 pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 4607 set(hset_object,'Position',pos_set_object) 4608 end 4609 list_object=get(handles.list_object_1,'String'); 4610 if ~isempty(list_object) 4611 set(handles.list_object_1,'Value',length(list_object)) 4612 end 4613 UvData.MouseAction='create_object'; 4577 % data.TITLE='MASK'; 4578 % if isfield(UvData,'CoordType') 4579 % data.CoordType=UvData.CoordType; 4580 % end 4581 % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4582 % data.YMax=UvData.Mesh; 4583 % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image 4584 % np=size(UvData.Field.A); 4585 % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1); 4586 % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1); 4587 % data.YMax=max(meshx,meshy); 4588 % data.DX=max(meshx,meshy); 4589 % end 4590 % data.Coord=[0 0 0]; %default 4591 % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters 4592 % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface 4593 % pos_uvmat=get(handles.uvmat,'Position'); 4594 % if isfield(UvData,'SetObjectOrigin') 4595 % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); 4596 % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 4597 % set(hset_object,'Position',pos_set_object) 4598 % end 4599 ListObj=UvData.Object; 4600 select=zeros(1,numel(ListObj)); 4601 for iobj=1:numel(ListObj); 4602 if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') 4603 select(iobj)=1; 4604 end 4605 end 4606 val=find(select); 4607 if isempty(val) 4608 msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); 4609 return 4610 else 4611 set(handles.list_object_1,'Max',2);%allow multiple selection 4612 set(handles.list_object_1,'Value',val); 4613 % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']); 4614 % if ~isempty(answer) 4615 flag=1; 4616 npx=size(UvData.Field.A,2); 4617 npy=size(UvData.Field.A,1); 4618 xi=[0.5:npx-0.5]; 4619 yi=[0.5:npy-0.5]; 4620 [Xi,Yi]=meshgrid(xi,yi); 4621 if isfield(UvData,'Object') 4622 for iobj=1:length(UvData.Object) 4623 ObjectData=UvData.Object{iobj}; 4624 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); 4625 flagobj=1; 4626 testphys=0; %coordinates in pixels by default 4627 if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') 4628 if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib') 4629 Calib=UvData.XmlData.GeometryCalib; 4630 testphys=1; 4631 end 4632 end 4633 if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') 4634 if isequal(ObjectData.Style,'polygon') 4635 X=ObjectData.Coord(:,1); 4636 Y=ObjectData.Coord(:,2); 4637 if testphys 4638 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 4639 end 4640 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside 4641 elseif isequal(ObjectData.Style,'ellipse') 4642 if testphys 4643 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4644 end 4645 RangeX=max(ObjectData.RangeX); 4646 RangeY=max(ObjectData.RangeY); 4647 X2Max=RangeX*RangeX; 4648 Y2Max=RangeY*RangeY; 4649 distX=(Xi-ObjectData.Coord(1,1)); 4650 distY=(Yi-ObjectData.Coord(1,2)); 4651 flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; 4652 elseif isequal(ObjectData.Style,'rectangle') 4653 if testphys 4654 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4655 end 4656 distX=abs(Xi-ObjectData.Coord(1,1)); 4657 distY=abs(Yi-ObjectData.Coord(1,2)); 4658 flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); 4659 end 4660 if isequal(ObjectData.ProjMode,'mask_outside') 4661 flagobj=~flagobj; 4662 end 4663 flag=flag & flagobj; 4664 end 4665 end 4666 end 4667 end 4668 % flag=~flag; 4669 %mask name 4670 RootPath=get(handles.RootPath,'String'); 4671 RootFile=get(handles.RootFile,'String'); 4672 if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\')) 4673 RootFile(1)=[]; 4674 end 4675 filebase=fullfile(RootPath,RootFile); 4676 list=get(handles.masklevel,'String'); 4677 masknumber=num2str(length(list)); 4678 maskindex=get(handles.masklevel,'Value'); 4679 mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); 4680 imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) 4681 imflag=flipdim(imflag,1); 4682 % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 4683 % 20<imflag<200) 4684 4685 %display the mask 4686 %update_mask(handles,num_i1,num_j1) 4687 figure; 4688 vec=linspace(0,1,256);%define a linear greyscale colormap 4689 map=[vec' vec' vec']; 4690 colormap(map) 4691 image(imflag); 4692 answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name) 4693 if ~strcmp(answer,'Cancel') 4694 imwrite(imflag,answer,'BitDepth',8); 4695 end 4696 set(list_object_1,'Value',1) 4697 set(list_object_1,'Max',1) 4698 % end 4699 end 4700 4701 4702 % UvData.MouseAction='create_object'; 4614 4703 set(handles.uvmat,'UserData',UvData); 4615 4704 … … 4779 4868 create_object(data,handles) 4780 4869 4870 %------------------------------------------------------------------------ 4871 function MenuMaskObject_Callback(hObject, eventdata, handles) 4872 %------------------------------------------------------------------------ 4873 data.Style='polygon'; 4874 data.StyleMenu={'polygon'}; 4875 data.ProjMode='mask_inside';%default 4876 data.ProjMenu={'mask_inside';'mask_outside'}; 4877 create_object(data,handles) 4878 4781 4879 % ------------------------------------------------------------------ 4782 4880 function Menuplane_Callback(hObject, eventdata, handles) … … 4852 4950 set(handles.edit,'BackgroundColor',[0.7,0.7,0.7]) 4853 4951 data.enable_plot=1; 4854 if isfield(UvData,'CoordType') 4855 data.CoordType=UvData.CoordType; 4856 end 4952 transform_list=get(handles.transform_fct,'String'); 4953 val=get(handles.transform_fct,'Value'); 4954 data.CoordType=transform_list{val}; 4955 % if isfield(UvData,'CoordType') 4956 % data.CoordType=UvData.CoordType; 4957 % end 4857 4958 if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4858 4959 data.RangeX=UvData.Mesh; … … 4934 5035 4935 5036 4936
Note: See TracChangeset
for help on using the changeset viewer.