Changeset 245 for trunk/src/series/relabel_i_j.m
- Timestamp:
- Apr 20, 2011, 12:52:35 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/relabel_i_j.m
r223 r245 1 2 % relabel_i_j: relabel an image series with two indices, and correct errors from the RDvision transfer program 1 %'relabel_i_j': relabel an image series with two indices, and correct errors from the RDvision transfer program 3 2 %---------------------------------------------------------------------- 4 3 function GUI_input=relabel_i_j(num_i1,num_i2,num_j1,num_j2,Series) … … 26 25 end 27 26 basename=fullfile(RootPath{1},RootFile{1}); 28 [XmlData,warntext]=imadoc2struct([basename '.xml']) ;% read the xml file appended to the present function (containing bug corrections)27 [XmlData,warntext]=imadoc2struct([basename '.xml'])% read the xml file appended to the present function (containing bug corrections) 29 28 if ~isempty(warntext) 30 29 msgbox_uvmat('ERROR',warntext)%error message for xml file reading … … 32 31 nbfield1=size(XmlData.Time,1); 33 32 nbfield2=size(XmlData.Time,2); 34 35 33 set(hseries.first_i,'String',num2str(first_label))% display the first image in the process 36 34 set(hseries.last_i,'String',num2str(nbfield1*nbfield2-1+first_label))% display the last image in the process … … 38 36 SeriesData=get(hGUI,'UserData'); 39 37 if ~strcmp(SeriesData.NomType,'_000001') 40 msgbox_uvmat('WARNING','the input is not a file from RDvision: this function relabel_i_j has no action') %error message for directory creation38 msgbox_uvmat('WARNING','the input is not a file from RDvision: this function relabel_i_j has no action');%error message for directory creation 41 39 return 42 40 else 43 msgbox_uvmat('CONFIRMATION','this function will relabel the file series from RDvision and correct the xml file')%error message for directory creation 41 answer=msgbox_uvmat('','this function will relabel the file series from RDvision and correct the xml file');%error message for directory creation 42 if ~strcmp(answer,'Yes') 43 return 44 end 44 45 end 45 46 … … 48 49 return 49 50 end 50 answer=msgbox_uvmat('CONFIRMATION',[num2str(nbfield1) ' bursts containing ' num2str(nbfield2) ' images each']);%error message for directory creation 51 if nbfield2>=2 52 answer=msgbox_uvmat('',[num2str(nbfield1) ' bursts containing ' num2str(nbfield2) ' images each']);%error message for directory creation 53 nomtype='_i_j'; 54 else 55 answer=msgbox_uvmat('',['image series with ' num2str(nbfield1) ' images']);%error message for directory creation 56 nomtype='_i'; 57 end 58 if ~strcmp(answer,'Yes') 59 return 60 end 51 61 52 62 %% copy and adapt the xml file … … 54 64 try 55 65 copyfile([basename '.xml'],[basename '.xml~']);% backup the xml file 56 catch 57 errormsg=lasterr 58 msgbox_uvmat('ERROR',errormsg); 66 catch ME 67 msgbox_uvmat('ERROR',ME.message); 59 68 return 60 69 end … … 81 90 82 91 %%%% correction RDvision %%%% 92 if isfield(XmlData,'NbDtj') 83 93 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 84 94 uid_value=children(t,uid_NbDtj); … … 86 96 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtj)); 87 97 end 98 end 99 if isfield(XmlData,'NbDtk') 88 100 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 89 101 uid_value=children(t,uid_NbDtk); … … 91 103 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtk)); 92 104 end 105 end 106 if strcmp(nomtype,'_i') && isfield(XmlData,'NbDti') 107 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti'); 108 uid_value=children(t,uid_NbDti); 109 if ~isempty(uid_value) 110 t=set(t,uid_value(1),'value',num2str(XmlData.NbDti)); 111 end 112 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 113 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 114 t=delete(t,uid_NbDtj); 115 t=delete(t,uid_NbDtk); 116 uid_Dtj=find(t,'ImaDoc/Camera/BurstTiming/Dtj'); 117 uid_Dtk=find(t,'ImaDoc/Camera/BurstTiming/Dtk'); 118 t=delete(t,uid_Dtj); 119 t=delete(t,uid_Dtk); 120 end 93 121 %%% 94 122 … … 97 125 98 126 %% main loop 127 99 128 for ifile=1:nbfield1*nbfield2 100 129 update_waitbar(hseries.waitbar,WaitbarPos,ifile/(nbfield1*nbfield2)) … … 102 131 num_j=mod(ifile-1+first_label,nbfield2)+1; 103 132 num_i=floor((ifile-1+first_label)/nbfield2)+1; 104 filename_new=name_generator(basename,num_i,num_j,'.png', '_i_j');133 filename_new=name_generator(basename,num_i,num_j,'.png',nomtype); 105 134 try 106 135 movefile(filename,filename_new); … … 115 144 return 116 145 end 117 % if test_level 118 % A=imread(filename); 119 % C=levels(A); 120 % imwrite(C,filename_new) 121 % else 122 % try 123 % copyfile(filename,filename_new); 124 % catch 125 % errormsg=lasterr 126 % msgbox_uvmat('ERROR',errormsg); 127 % return 128 % end 129 % end 130 end 131 132 133 function C=levels(A) 134 %whos A; 135 B=double(A(:,:,1)); 136 windowsize=round(min(size(B,1),size(B,2))/20); 137 windowsize=floor(windowsize/2)*2+1; 138 ix=[1/2-windowsize/2:-1/2+windowsize/2];% 139 %del=np/3; 140 %fct=exp(-(ix/del).^2); 141 fct2=cos(ix/(windowsize-1)/2*pi/2); 142 %Mfiltre=(ones(5,5)/5^2); 143 %Mfiltre=fct2'; 144 Mfiltre=fct2'*fct2; 145 Mfiltre=Mfiltre/(sum(sum(Mfiltre))); 146 147 C=filter2(Mfiltre,B); 148 C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize); 149 C(:,end-windowsize+1:end)=C(:,end-windowsize+1)*ones(1,windowsize); 150 C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:); 151 C(end-windowsize+1:end,:)=ones(windowsize,1)*C(end-windowsize,:); 152 C=tanh(B./(2*C)); 153 [n,c]=hist(reshape(C,1,[]),100); 154 % figure;plot(c,n); 155 156 [m,i]=max(n); 157 c_max=c(i); 158 [dummy,index]=sort(abs(c-c(i))); 159 n=n(index); 160 c=c(index); 161 i_select = find(cumsum(n)<0.95*sum(n)); 162 if isempty(i_select) 163 i_select = 1:length(c); 164 end 165 c_select=c(i_select); 166 n_select=n(i_select); 167 cmin=min(c_select); 168 cmax=max(c_select); 169 C=(C-cmin)/(cmax-cmin)*256; 170 C=uint8(C); 146 end 147 171 148 172 149 %'imadoc2struct': reads the xml file for image documentation … … 256 233 NbDtj=get_value(subt,'/BurstTiming/NbDtj',1); 257 234 %%%% correction RDvision %%%% 258 NbDtj=NbDtj/numel(Dtj); 259 s.NbDtj=NbDtj; 260 %%%% 261 Dti=get_value(subt,'/BurstTiming/Dti',[]); 235 % NbDtj=NbDtj/numel(Dtj); 236 % s.NbDtj=NbDtj; 237 % %%%% 238 Dti=get_value(subt,'/BurstTiming/Dti',[]) 239 NbDti=get_value(subt,'/BurstTiming/NbDti',1) 240 %%%% correction RDvision %%%% 241 if isempty(Dti)% series 242 Dti=Dtj 243 NbDti=NbDtj 244 Dtj=[]; 245 s.Dti=Dti; 246 'TESTrxml' 247 s.NbDti=NbDti 248 else 249 NbDtj=NbDtj/numel(Dtj);%bursts 250 s.NbDtj=NbDtj; 251 end 252 %%%% %%%% 262 253 Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's') 263 NbDti=get_value(subt,'/BurstTiming/NbDti',1); 254 264 255 Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit 265 256 if ~isempty(Dti)
Note: See TracChangeset
for help on using the changeset viewer.