- Timestamp:
- May 25, 2015, 8:48:58 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r896 r897 1556 1556 end 1557 1557 1558 %% set nbre of cluster cores and processes 1558 %% set nbre of cluster cores and processes: 1559 % NbCore is the number of computer processors used 1560 % NbProcess is the number of independent processes in which the required calculation is split 1559 1561 switch RunMode 1560 1562 case {'local','background'} … … 1598 1600 end 1599 1601 if isempty(Param.IndexRange.NbSlice) 1600 NbProcess=NbCore;% choose one process per core 1602 NbProcess=NbCore;% choose one process per core if NbSlice is not imposed 1601 1603 else 1602 NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices1603 NbCore=min(NbCore,NbProcess);% at least one process per core1604 NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes 1605 NbCore=min(NbCore,NbProcess);% reduces the number of cores if it exceeds the number of processes 1604 1606 end 1605 1607 … … 1662 1664 OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files 1663 1665 1664 %% get the set of reference field indices1665 first_i=1; 1666 last_i=1; 1667 incr_i=1; 1668 first_j=1; 1669 last_j=1; 1670 incr_j=1; 1666 %% get the set of reference input field indices 1667 first_i=1;% first i index to process 1668 last_i=1;% last i index to process 1669 incr_i=1;% increment step in i index 1670 first_j=1;% first j index to process 1671 last_j=1;% last j index to process 1672 incr_j=1;% increment step in j index 1671 1673 if isfield(Param.IndexRange,'first_i') 1672 1674 first_i=Param.IndexRange.first_i; … … 1688 1690 set(handles.num_incr_i,'String','1') 1689 1691 end 1692 % case of no increment i defined: processing is done on the available files found in i1_series 1690 1693 if isempty(incr_i) 1691 1694 if isempty(incr_j) … … 1701 1704 ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); 1702 1705 end 1706 % increment i is defined: processing is done on first_i:incr_i:last_i; 1703 1707 else 1704 1708 ref_i=first_i:incr_i:last_i; … … 1711 1715 end 1712 1716 end 1713 BlockLength=ceil(numel(ref_i)/NbProcess); 1714 nbfield_j=numel(ref_j); 1717 BlockLength=ceil(numel(ref_i)/NbProcess);% nbre of input fields in each process 1718 nbfield_j=numel(ref_j); % number of j indices 1715 1719 1716 1720 %% record nbre of output files and starting time for computation for status … … 1729 1733 set(handles.status,'UserData',StatusData) 1730 1734 1731 1735 %% case of a function in Python 1732 1736 if strcmp(ActionExt, '.py (in dev.)') 1733 1737 fprintf([ … … 1759 1763 %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i); 1760 1764 else %multislices (then incr_i is not empty) 1761 1762 1765 Param.IndexRange.first_i= first_i+incr_i*(iprocess-1); 1766 Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; 1763 1767 end 1764 1768 if isfield(Param,'OutputSubDir') 1765 t=struct2xml(Param);1766 t=set(t,1,'name','Series');1767 filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,...1768 Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);1769 save(t,filexml);1769 t=struct2xml(Param); 1770 t=set(t,1,'name','Series'); 1771 filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... 1772 Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); 1773 save(t,filexml); 1770 1774 end 1771 1775 switch ActionExt … … 1895 1899 for iprocess=1:NbProcess 1896 1900 system([batch_file_list{iprocess} ' &'])% directly execute the command file for each process 1897 msgbox_uvmat('CONFIRMATION',[ActionName ' launched in background: press STATUS to see results'])1898 end1901 end 1902 msgbox_uvmat('CONFIRMATION',[ActionName ' launched in background: press STATUS to see results']) 1899 1903 case 'cluster_oar' % option 'oar-parexec' used 1900 1904 %create subdirectory for oar command and log files … … 2041 2045 drawnow 2042 2046 2043 %% check whether the input file(s) need to be refreshed2044 % SeriesData=get(handles.series,'UserData');%hidden parameters2045 % if ~isfield(SeriesData,'i1_series')2046 % msgbox_uvmat('ERROR','The input field series needs to be refreshed: press REFRESH');2047 % return2048 % end2049 2050 2047 %% get Action name and path 2051 2048 NbBuiltinAction=get(handles.Action,'UserData'); %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series) … … 2106 2103 set(handles.ActionName,'UserData',ActionPathList); 2107 2104 set(handles.ActionExt,'Value',ActionExtIndex) 2108 % ActionPathList{ActionIndex,ActionExtIndex}=PathName;2109 2105 2110 2106 %record the user defined menu additions in personal file profil_perso … … 2134 2130 2135 2131 %% create the function handle for Action 2136 path_series=which('series'); 2137 if ~isequal(ActionPath,path_series) 2138 eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION 2139 if ~exist(ActionPath,'dir') 2140 errormsg=['The prescribed function path ' ActionPath ' does not exist']; 2141 return 2142 end 2143 if ~isequal(spath,ActionPath) 2144 addpath(ActionPath)% add the prescribed path if not the current one 2145 end 2146 end 2147 eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION 2148 if ~isequal(ActionPath,path_series) 2149 rmpath(ActionPath)% add the prescribed path if not the current one 2150 end 2132 if ~exist(ActionPath,'dir') 2133 msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']); 2134 return 2135 end 2136 current_dir=pwd;%current working dir 2137 cd(ActionPath) 2138 h_fun=str2func(ActionName); 2139 cd(current_dir) 2140 2141 % 2142 % checkaddpath=0; 2143 % path_series=which('series'); 2144 % %eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION 2145 % spath=fileparts(which(ActionName)); %spath = current path of the selected function ACTION 2146 % if ~exist(ActionPath,'dir') 2147 % msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']); 2148 % return 2149 % end 2150 % if ~strcmp(spath,ActionPath) 2151 % if strcmp(pwd,spath) 2152 % msgbox_uvmat('ERROR',[ 'a function called ' ActionName ' on your working space oversets the selected one']); 2153 % return 2154 % else 2155 % addpath(ActionPath)% add the prescribed path if not the current one 2156 % checkaddpath=1; 2157 % end 2158 % end 2159 % eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION 2160 % if checkaddpath && ~isequal(ActionPath,path_series) 2161 % rmpath(ActionPath)% add the prescribed path if not the current one 2162 % end 2151 2163 2152 2164 %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData … … 2185 2197 FieldList_1=get(handles.FieldName_1,'String');% previous list as default 2186 2198 if ~iscell(FieldList_1),FieldList_1={FieldList_1};end 2187 CheckList=0;% indicate whether FieldName has been updated2199 %CheckList=0;% indicate whether FieldName has been updated 2188 2200 CheckList_1=1;% indicate whether FieldName_1 has been updated 2189 2201 handles_coord=[handles.Coord_x handles.Coord_y handles.Coord_z handles.Coord_x_title handles.Coord_y_title handles.Coord_z_title]; … … 2195 2207 set(handles.VelType_title,'Visible','on') 2196 2208 FieldList=[set_field_list('U','V');{'C'};{'get_field...'}];%standard menu for civx data 2197 CheckList=1;2209 %CheckList=1; 2198 2210 set(handles.FieldName,'Value',1); %velocity vector choice by default 2199 2211 if VelTypeRequest_1 && numel(iview_civ)>=2 … … 2347 2359 2348 2360 %% NbSlice visibility 2349 NbSliceVisible='off';%default2350 if isfield(ParamOut,'NbSlice') && isequal(ParamOut.NbSlice,'on')2351 NbSliceVisible='on';2352 set(handles. num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices2361 %NbSliceVisible='off';%default 2362 if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice)) 2363 set(handles.num_NbSlice,'Visible','on') 2364 set(handles.NbSlice_title,'Visible','on') 2353 2365 else 2354 set(handles.num_NbProcess,'String','')% free nbre of processes 2355 end 2356 set(handles.num_NbSlice,'Visible',NbSliceVisible) 2357 set(handles.NbSlice_title,'Visible',NbSliceVisible) 2366 set(handles.num_NbSlice,'Visible','off') 2367 set(handles.NbSlice_title,'Visible','off') 2368 % set(handles.num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices 2369 % else 2370 % set(handles.num_NbProcess,'String','')% free nbre of processes 2371 end 2372 if isnumeric(ParamOut.NbSlice) 2373 set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice)) 2374 set(handles.num_NbSlice,'Enable','off'); % NbSlice set by the activation of the Action function 2375 else 2376 set(handles.num_NbSlice,'Enable','on'); % NbSlice can be modified on the GUI series 2377 end 2378 % set(handles.num_NbSlice,'Visible',NbSliceVisible) 2379 % set(handles.NbSlice_title,'Visible',NbSliceVisible) 2358 2380 2359 2381 … … 3003 3025 %% create the function handle of the selected fct 3004 3026 if ~isempty(TransformName) 3027 if ~exist(TransformPathList{TransformIndex},'dir') 3028 msgbox_uvmat('ERROR',['The prescribed transform function path ' TransformPathList{TransformIndex} ' does not exist']); 3029 return 3030 end 3005 3031 current_dir=pwd;%current working dir 3006 3032 cd(TransformPathList{TransformIndex}) … … 3294 3320 end 3295 3321 3296 function num_NbProcess_Callback(hObject, eventdata, handles)3322 %function num_NbProcess_Callback(hObject, eventdata, handles) 3297 3323 3298 3324 3299 3325 function num_NbSlice_Callback(hObject, eventdata, handles) 3300 3326 NbSlice=str2num(get(handles.num_NbSlice,'String')); 3301 set(handles.num_NbProcess,'String',num2str(NbSlice))3327 %set(handles.num_NbProcess,'String',num2str(NbSlice)) 3302 3328 3303 3329 %------------------------------------------------------------------------ -
trunk/src/series/civ_input.m
r885 r897 1793 1793 end 1794 1794 Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B) 1795 Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1796 Param.IndexRange.last_i=str2num(get(handles.ref_i,'String')); 1797 if strcmp(get(handles.ref_j,'Visible'),'on') 1798 Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1799 Param.IndexRange.last_j=Param.IndexRange.first_j; 1800 else 1801 Param.IndexRange.first_j=1; 1802 Param.IndexRange.last_j=1; 1803 end 1795 1804 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1796 1805 if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series -
trunk/src/series/civ_series.m
r896 r897 355 355 % if Civ1 computation is requested 356 356 if isfield (Param.ActionInput,'Civ1') 357 if CheckInputFile 357 358 disp('civ1 started') 359 end 358 360 par_civ1=Param.ActionInput.Civ1; 359 361 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) -
trunk/src/series/sub_background.m
r854 r897 75 75 ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 76 76 ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 77 ParamOut.NbSlice='on'; % nbre of slices ('off' by default)77 ParamOut.NbSlice='on'; % edit box nbre of slices made active 78 78 ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 79 79 ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) … … 117 117 118 118 %% numbers of fields 119 NbSlice =1;%default119 NbSlice_i=1;%default 120 120 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) 121 NbSlice =Param.IndexRange.NbSlice;121 NbSlice_i=Param.IndexRange.NbSlice; 122 122 end 123 123 incr_j=1;%default … … 130 130 nbfield_j=numel(first_j:incr_j:last_j);%nb of fields for the j index (bursts or volume slices) 131 131 end 132 incr_i=1;%default 133 first_i=1;last_i=1;incr_i;%default 132 first_i=1;last_i=1;incr_i=1;%default 134 133 if isfield(Param.IndexRange,'first_i'); last_i=Param.IndexRange.first_i; end 135 134 if isfield(Param.IndexRange,'last_i'); last_i=Param.IndexRange.last_i; end … … 139 138 nbfield_i=numel(first_i:incr_i:last_i);%nb of fields for the i index (bursts or volume slices) 140 139 nbfield=nbfield_j*nbfield_i; %total number of fields 141 nbfield_i=floor(nbfield/NbSlice );%total number of indexes in a slice (adjusted to an integer number of slices)140 nbfield_i=floor(nbfield/NbSlice_i);%total number of indexes in a slice (adjusted to an integer number of slices) 142 141 143 142 %% setting of parameters specific to sub_background … … 159 158 160 159 %check input consistency 161 if strcmp(answer{1},'No') && ~isequal(NbSlice ,1)162 check=msgbox_uvmat('INPUT_Y-N',['confirm the multi-level splitting into ' num2str(NbSlice ) ' slices']);160 if strcmp(answer{1},'No') && ~isequal(NbSlice_i,1) 161 check=msgbox_uvmat('INPUT_Y-N',['confirm the multi-level splitting into ' num2str(NbSlice_i) ' slices']); 163 162 if ~strcmp(check,'Yes') 164 163 return … … 166 165 end 167 166 if strcmp(answer{1},'Yes') 168 step=1; 167 step=2;%the sliding background is shifted by the length of one burst, assumed =2 for volume ;ode 168 ParamOut.NbSlice=1; %nbre of slices displayed 169 169 else 170 170 step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst … … 198 198 199 199 %% input preparation 200 NbSlice =Param.IndexRange.NbSlice;201 if ~isequal(NbSlice ,1)202 display(['multi-level splitting into ' num2str(NbSlice ) ' slices']);200 NbSlice_i=Param.IndexRange.NbSlice; 201 if ~isequal(NbSlice_i,1) 202 display(['multi-level splitting into ' num2str(NbSlice_i) ' slices']); 203 203 end 204 204 RootPath=Param.InputTable(:,1); … … 207 207 NomType=Param.InputTable(:,4); 208 208 FileExt=Param.InputTable(:,5); 209 hdisp=disp_uvmat('WAITING...','checking the file series',checkrun);210 [filecell,i1_series,i2_series,j1_series ,j2_series]=get_file_series(Param);211 if ~isempty(hdisp),delete(hdisp),end;209 %hdisp=disp_uvmat('WAITING...','checking the file series',checkrun); 210 [filecell,i1_series,i2_series,j1_series]=get_file_series(Param); 211 % if ~isempty(hdisp),delete(hdisp),end; 212 212 %%%%%%%%%%%% 213 213 % The cell array filecell is the list of input file names, while … … 225 225 frame_index{1}=i1_series{1}; 226 226 end 227 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 228 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 229 nbfield=nbfield_j*nbfield_i; %total number of fields 230 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 231 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement 232 233 %% output 227 228 229 %% output file naming 234 230 FileExtOut='.png'; % write result as .png images for image inputs 235 231 if strcmp(lower(NomType{1}(end)),'a') … … 240 236 NomTypeOut='_1_1';% caseof purely numerical indexing 241 237 end 242 243 238 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 244 239 245 if isequal(Param.ActionInput.CheckVolume,1) 246 step=1; 247 else 240 %% file index parameters 241 % NbSlice_i: nbre of slices for i index: different of of 1 for multi-level, 242 % the function sub_background is then relaunched by the GUI series for each 243 % slice, incrementing the first index i by 1 244 % NbSlice_j: nbre of slices in volume mode 245 % nbfield : total number of images treated per slice 246 % step: shift of image index at each step of the sliding background (corresponding to the nbre of images in a burst) 247 % nbaver_ima: nbre of the images in the sliding sequence used for the background 248 % nbaver=nbaver_ima/step: nbre of bursts corresponding to nbaver_ima images. It has been adjusted so that nbaver is an odd integer 249 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 250 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 251 nbfield=nbfield_j*nbfield_i; %total number of fields 252 if Param.ActionInput.CheckVolume 253 step=2;% we assume the burst contains only one image pair 254 NbSlice_j=nbfield_j; 255 NbSlice=nbfield_j; 256 nbfield_series=nbfield_i; 257 else 248 258 step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst 259 NbSlice_j=1; 260 NbSlice=NbSlice_i; 261 nbfield_i=floor(nbfield/NbSlice_i);%total number of indexes in a slice (adjusted to an integer number of slices) 262 nbfield=nbfield_i*NbSlice_i; %total number of fields after adjustement 263 nbfield_series=nbfield; 249 264 end 250 265 nbaver_ima=Param.ActionInput.SlidingSequenceLength;%number of images for the sliding background … … 258 273 return 259 274 end 260 261 % calculate absolute brightness rank 275 halfnbaver=floor(nbaver/2); % half width (in unit of bursts) of the sliding background 276 277 %% calculate absolute brightness rank 262 278 rank=floor(Param.ActionInput.BrightnessRankThreshold*nbaver_ima); 263 279 if rank==0 … … 281 297 end 282 298 283 %% summary of the parameters: 284 % nbfield : total number of images treated (in case of multislices the function sub_background is repeated for each slice) 285 % step: shift at each step of the sliding background (corresponding to the nbre of images in a burst) 286 % nbaver_ima: length of the sequence used for the sliding background 287 288 % nbaver=nbaver_ima/step: nbaver_ima has been adjusted so that nbaver is an odd integer 289 halfnbaver=floor(nbaver/2); % half width (in unit of bursts) of the sliding background 290 291 %% select the series of image indices to process 292 indselect=1:step:nbfield;% select file indices of the slice 293 for ifield=1:step-1 294 indselect=[indselect;indselect(end,:)+1]; 295 end 296 297 %% read the first series of nbaver_ima images and sort by luminosity at each pixel 298 for ifield = 1:nbaver_ima 299 ifile=indselect(ifield); 300 filename=filecell{1,ifile}; 301 Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile)); 302 if ndims(Aread)==3;%color images 303 Aread=sum(double(Aread),3);% take the sum of color components 304 end 305 Ak(:,:,ifield)=Aread; 306 end 307 Asort=sort(Ak,3);%sort the luminosity of images at each point 308 B=Asort(:,:,rank);%background image 309 310 %% substract the first background image to the first images 311 display( 'first background image will be substracted') 312 for ifield=1:step*(halfnbaver+1);% nbre of images treated by the first background image 313 Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image 314 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 315 ifile=indselect(ifield); 316 j1=1; 317 if ~isempty(j1_series{1}) 318 j1=j1_series{1}(ifile); 319 end 320 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 321 322 %write result file 323 if Param.ActionInput.CheckLevelTransform 324 C=levels(Acor); 325 imwrite(C,newname,'BitDepth',8); % save the new image 326 else 327 if isequal(FileInfo{1}.BitDepth,16) 328 C=uint16(Acor); 329 imwrite(C,newname,'BitDepth',16); % save the new image 299 300 %%%%%%% LOOP ON SLICES FOR VOLUME SCAN %%%%%%% 301 for j_slice=1:NbSlice_j 302 %% select the series of i indices to process 303 indselect=j_slice:step*NbSlice_j:nbfield;% select file indices of the slice 304 for ifield=1:step-1 305 indselect=[indselect;indselect(end,:)+NbSlice_j]; 306 end 307 308 %% read the first series of nbaver_ima images and sort by luminosity at each pixel 309 for ifield = 1:nbaver_ima 310 ifile=indselect(ifield); 311 filename=filecell{1,ifile}; 312 Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile)); 313 if ndims(Aread)==3;%color images 314 Aread=sum(double(Aread),3);% take the sum of color components 315 end 316 Ak(:,:,ifield)=Aread; 317 end 318 Asort=sort(Ak,3);%sort the luminosity of images at each point 319 B=Asort(:,:,rank);%background image 320 321 %% substract the first background image to the first images 322 display( 'first background image will be substracted') 323 for ifield=1:step*(halfnbaver+1);% nbre of images treated by the first background image 324 Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image 325 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 326 ifile=indselect(ifield); 327 j1=1; 328 if ~isempty(j1_series{1}) 329 j1=j1_series{1}(ifile); 330 end 331 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 332 333 %write result file 334 if Param.ActionInput.CheckLevelTransform 335 C=levels(Acor); 336 imwrite(C,newname,'BitDepth',8); % save the new image 330 337 else 331 C=uint8(Acor); 338 if isequal(FileInfo{1}.BitDepth,16) 339 C=uint16(Acor); 340 imwrite(C,newname,'BitDepth',16); % save the new image 341 else 342 C=uint8(Acor); 343 imwrite(C,newname,'BitDepth',8); % save the new image 344 end 345 end 346 display([newname ' written']) 347 end 348 349 %% repeat the operation on a sliding series of images 350 display('sliding background image will be substracted') 351 if nbfield_series > nbaver_ima 352 for ifield = step*(halfnbaver+1):step:nbfield_series-step*(halfnbaver+1)% ifield +iburst=index of the current processed image 353 update_waitbar(WaitbarHandle,ifield/nbfield_series) 354 if ~strcmp(get(RUNHandle,'BusyAction'),'queue') 355 disp('program stopped by user') 356 return 357 end 358 if nbaver_ima>step 359 Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step) 360 end 361 %incorporate next burst in the current image series 362 for iburst=1:step 363 ifile=indselect(ifield+iburst+step*halfnbaver); 364 j1=1; 365 if ~isempty(j1_series{1}) 366 j1=j1_series{1}(ifile); 367 end 368 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1); 369 Aread=read_image(filename,FileType{1},MovieObject{1},i1_series{1}(ifile)); 370 if ndims(Aread)==3;%color images 371 Aread=sum(double(Aread),3);% take the sum of color components 372 end 373 Ak(:,:,nbaver_ima-step+iburst)=Aread;% fill the last burst of the current image series by the new image 374 end 375 Asort=sort(Ak,3);%sort the new current image series by luminosity 376 B=Asort(:,:,rank);%current background image 377 %substract the background for the current burst 378 for iburst=1:step 379 Acor=double(Ak(:,:,step*halfnbaver+iburst))-double(B); %the current image has been already read ans stored as index step*halfnbaver+iburst in the current series 380 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 381 ifile=indselect(ifield+iburst); 382 if ~isempty(j1_series{1}) 383 j1=j1_series{1}(ifile); 384 end 385 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 386 %write result file 387 if Param.ActionInput.CheckLevelTransform 388 C=levels(Acor); 389 imwrite(C,newname,'BitDepth',8); % save the new image 390 else 391 if isequal(FileInfo{1}.BitDepth,16) 392 C=uint16(Acor); 393 imwrite(C,newname,'BitDepth',16); % save the new image 394 else 395 C=uint8(Acor); 396 imwrite(C,newname,'BitDepth',8); % save the new image 397 end 398 end 399 display([newname ' written']) 400 end 401 end 402 end 403 404 %% substract the background from the last images 405 display('last background image will be substracted') 406 for ifield=nbfield_series-step*halfnbaver+1:nbfield_series 407 Acor=double(Ak(:,:,ifield-nbfield_series+step*(2*halfnbaver+1)))-double(B); 408 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 409 ifile=indselect(ifield); 410 if ~isempty(j1_series{1}) 411 j1=j1_series{1}(ifile); 412 end 413 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 414 %write result file 415 if Param.ActionInput.CheckLevelTransform 416 C=levels(Acor); 332 417 imwrite(C,newname,'BitDepth',8); % save the new image 333 end 334 end 335 display([newname ' written']) 336 end 337 338 %% repeat the operation on a sliding series of images 339 display('sliding background image will be substracted') 340 if nbfield_i > nbaver_ima 341 for ifield = step*(halfnbaver+1):step:nbfield_i-step*(halfnbaver+1)% ifield +iburst=index of the current processed image 342 update_waitbar(WaitbarHandle,ifield/nbfield_i) 343 if ~isempty(RUNHandle) &&ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 344 disp('program stopped by user') 345 return 346 end 347 Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step) 348 %incorporate next burst in the current image series 349 for iburst=1:step 350 ifile=indselect(ifield+iburst+step*halfnbaver); 351 j1=1; 352 if ~isempty(j1_series{1}) 353 j1=j1_series{1}(ifile); 354 end 355 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1); 356 Aread=read_image(filename,FileType{1},MovieObject{1},i1_series{1}(ifile)); 357 if ndims(Aread)==3;%color images 358 Aread=sum(double(Aread),3);% take the sum of color components 359 end 360 Ak(:,:,nbaver_ima-step+iburst)=Aread;% fill the last burst of the current image series by the new image 361 end 362 Asort=sort(Ak,3);%sort the new current image series by luminosity 363 B=Asort(:,:,rank);%current background image 364 %substract the background for the current burst 365 for iburst=1:step 366 Acor=double(Ak(:,:,step*halfnbaver+iburst))-double(B); %the current image has been already read ans stored as index step*halfnbaver+iburst in the current series 367 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 368 ifile=indselect(ifield+iburst); 369 if ~isempty(j1_series{1}) 370 j1=j1_series{1}(ifile); 371 end 372 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 373 %write result file 374 if Param.ActionInput.CheckLevelTransform 375 C=levels(Acor); 418 else 419 if isequal(FileInfo{1}.BitDepth,16) 420 C=uint16(Acor); 421 imwrite(C,newname,'BitDepth',16); % save the new image 422 else 423 C=uint8(Acor); 376 424 imwrite(C,newname,'BitDepth',8); % save the new image 377 else 378 if isequal(FileInfo{1}.BitDepth,16) 379 C=uint16(Acor); 380 imwrite(C,newname,'BitDepth',16); % save the new image 381 else 382 C=uint8(Acor); 383 imwrite(C,newname,'BitDepth',8); % save the new image 384 end 385 end 386 display([newname ' written']) 387 end 388 end 389 end 390 391 %% substract the background from the last images 392 display('last background image will be substracted') 393 for ifield=nbfield_i-step*halfnbaver+1:nbfield_i 394 Acor=double(Ak(:,:,ifield-nbfield_i+step*(2*halfnbaver+1)))-double(B); 395 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 396 ifile=indselect(ifield); 397 if ~isempty(j1_series{1}) 398 j1=j1_series{1}(ifile); 399 end 400 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 401 %write result file 402 if Param.ActionInput.CheckLevelTransform 403 C=levels(Acor); 404 imwrite(C,newname,'BitDepth',8); % save the new image 405 else 406 if isequal(FileInfo{1}.BitDepth,16) 407 C=uint16(Acor); 408 imwrite(C,newname,'BitDepth',16); % save the new image 409 else 410 C=uint8(Acor); 411 imwrite(C,newname,'BitDepth',8); % save the new image 412 end 413 end 414 display([newname ' written']) 415 end 416 425 end 426 end 427 display([newname ' written']) 428 end 429 end 417 430 418 431 -
trunk/src/transform_field/ima_remove_background.m
r810 r897 54 54 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 55 55 ImPart=(A-B); 56 DataOut.A=ImPart.*(ImPart>threshold); 56 DataOut.A=ImPart; 57 %DataOut.A=ImPart.*(ImPart>threshold); 57 58 DataOut.A=feval(Atype,DataOut.A); -
trunk/src/transform_field/ima_remove_particles.m
r810 r897 32 32 if strcmp(DataIn,'*') 33 33 return 34 34 35 end 35 36 36 37 %parameters 37 38 threshold=200; 38 nblock_x= 30;%size of image subblocks for analysis39 nblock_y= 30;39 nblock_x=10;%size of image subblocks for analysis 40 nblock_y=10; 40 41 %--------------------------------------------------------- 41 42 DataOut=DataIn;%default … … 49 50 Atype=class(DataIn.A); 50 51 A=double(DataIn.A); 51 Backg=zeros(size(A));52 % Backg=zeros(size(A)); 52 53 Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima 53 54 Amin=A.*Aflagmin;%values of A at local minima … … 58 59 Backg=Backg./Bmin; % find the average of minima in blocks 59 60 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 60 ImPart=(A-B); 61 ImPart=ImPart.*(ImPart>threshold); 62 DataOut.A=A-ImPart;% 61 DataOut.A=B; 62 % ImPart=(A-B); 63 % ImPart=ImPart.*(ImPart>threshold); 64 % DataOut.A=A-ImPart;% 63 65 DataOut.A=feval(Atype,DataOut.A); 64 66
Note: See TracChangeset
for help on using the changeset viewer.