Changeset 673
- Timestamp:
- Aug 6, 2013, 3:47:29 PM (11 years ago)
- Location:
- trunk/src/series
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r668 r673 90 90 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 91 91 %%%%%%%%%%%% 92 nbview=numel(i1_series);%number of input file series (lines in InputTable)93 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)94 nbfield_i=size(i1_series{1},2); %nb of fields for the i index95 nbfield=nbfield_j*nbfield_i; %total number of fields92 NbView=numel(i1_series);%number of input file series (lines in InputTable) 93 NbField_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 94 NbField_i=size(i1_series{1},2); %nb of fields for the i index 95 NbField=NbField_j*NbField_i; %total number of fields 96 96 97 97 %% determine the file type on each line from the first input file 98 98 ImageTypeOptions={'image','multimage','mmreader','video'}; 99 99 NcTypeOptions={'netcdf','civx','civdata'}; 100 for iview=1: nbview100 for iview=1:NbView 101 101 if ~exist(filecell{iview,1}','file') 102 102 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist']) … … 142 142 return 143 143 end 144 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2})144 if NbView==2 && ~isequal(CheckImage{1},CheckImage{2}) 145 145 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') 146 146 return … … 163 163 InputFields{1}=Param.InputFields; 164 164 end 165 if nbview==2165 if NbView==2 166 166 InputFields{2}=[];%default (case of images) 167 167 if isfield(Param,'InputFields') … … 182 182 183 183 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 184 for index=1: nbfield185 update_waitbar(WaitbarHandle,index/ nbfield)184 for index=1:NbField 185 update_waitbar(WaitbarHandle,index/NbField) 186 186 if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') 187 187 disp('program stopped by user') … … 190 190 191 191 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 192 for iview=1: nbview192 for iview=1:NbView 193 193 % reading input file(s) 194 194 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index)); -
trunk/src/series/merge_proj.m
r670 r673 106 106 NbField=NbField_j*NbField_i; %total number of fields 107 107 108 % determine the file type on each line from the first input file108 %% determine the file type on each line from the first input file 109 109 ImageTypeOptions={'image','multimage','mmreader','video'}; 110 110 NcTypeOptions={'netcdf','civx','civdata'}; … … 145 145 146 146 %% check the validity of input file types 147 if CheckImage{1}148 FileExtOut='.png'; % write result as .png images for image inputs149 elseif CheckNc{1}150 FileExtOut='.nc';% write result as .nc files for netcdf inputs151 else152 disp_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun)153 return154 end155 147 for iview=1:NbView 156 if ~isequal(CheckImage{iview}, CheckImage{1})||~isequal(CheckNc{iview},CheckNc{1})148 if ~isequal(CheckImage{iview},1)&&~isequal(CheckNc{iview},1) 157 149 disp_uvmat('ERROR','input set of input series: need either netcdf either image series',checkrun) 158 150 return 159 151 end 160 152 end 153 154 %% output file type 155 if min(cell2mat(CheckImage))==1 && (~Param.CheckObject || strcmp(Param.ProjObject.Type,'plane')) 156 FileExtOut='.png'; %image output (input and proj result = image) 157 for iview=1:NbView 158 BitDepth(iview)=FileInfo{iview}.BitDepth; 159 end 160 BitDepth=max(BitDepth); 161 else 162 FileExtOut='.nc'; %netcdf output 163 end 161 164 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series 165 RootFileOut=RootFile{1}; 166 for iview=2:NbView 167 if ~strcmp(RootFile{iview},RootFile{1}) 168 RootFileOut='mproj'; 169 break 170 end 171 end 162 172 163 173 %% mask (TODO: case of multilevels) … … 165 175 if Param.CheckMask 166 176 for iview=1:numel(Param.MaskTable) 167 % MaskData=cell(NbView,1); 168 % MaskSubDir=regexprep(Param.InputTable{iview,2},'\..*','');%take the root part of SubDir, before the first dot '.' 169 % MaskName=fullfile(Param.InputTable{iview,1},[MaskSubDir '.mask'],'mask_1.png'); 170 % if exist(MaskName,'file') 171 [MaskData{iview},tild,errormsg] = read_field(Param.MaskTable{iview},'image'); 172 if ~isempty(transform_fct) && nargin(transform_fct)>=2 173 MaskData{iview}=transform_fct(MaskData{iview},XmlData{iview}); 177 if exist(Param.MaskTable{iview},'file') 178 [MaskData{iview},tild,errormsg] = read_field(Param.MaskTable{iview},'image'); 179 if ~isempty(transform_fct) && nargin(transform_fct)>=2 180 MaskData{iview}=transform_fct(MaskData{iview},XmlData{iview}); 181 end 174 182 end 175 183 end … … 193 201 return 194 202 end 203 195 204 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 196 205 Data=cell(1,NbView);%initiate the set Data … … 239 248 end 240 249 end 241 % ----------END LOOP ON VIEWS----------------------250 %%%%%%%%%%%%%%%% END LOOP ON VIEWS %%%%%%%%%%%%%%%% 242 251 243 252 %% merge the NbView fields … … 248 257 end 249 258 250 % time of the merged field:259 %% time of the merged field: take the average of the different views 251 260 if ~isempty(time)% time defined from ImaDoc 252 261 timeread=time(:,index); … … 254 263 timeread=mean(timeread); 255 264 256 % generating the name of the merged field257 i1=i1_series{ iview}(index);258 if ~isempty(i2_series{ iview})259 i2=i2_series{ iview}(index);265 %% generating the name of the merged field 266 i1=i1_series{1}(index); 267 if ~isempty(i2_series{end}) 268 i2=i2_series{end}(index); 260 269 else 261 270 i2=i1; … … 263 272 j1=1; 264 273 j2=1; 265 if ~isempty(j1_series{ iview})266 j1=j1_series{ iview}(index);267 if ~isempty(j2_series{ iview})268 j2=j2_series{ iview}(index);274 if ~isempty(j1_series{1}) 275 j1=j1_series{1}(index); 276 if ~isempty(j2_series{end}) 277 j2=j2_series{end}(index); 269 278 else 270 279 j2=j1; 271 280 end 272 281 end 273 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2); 274 275 % recording the merged field 276 if CheckImage{1} %in case of input images an image is produced 277 if isa(MergeData.A,'uint8') 278 bitdepth=8; 279 elseif isa(MergeData.A,'uint16') 280 bitdepth=16; 281 end 282 imwrite(MergeData.A,OutputFile,'BitDepth',bitdepth); 283 %write xml calibration file 284 siz=size(MergeData.A); 285 npy=siz(1); 286 npx=siz(2); 287 if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1') 288 Rangx=MergeData.VarAttribute{1}.Coord_2; 289 Rangy=MergeData.VarAttribute{1}.Coord_1; 290 elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY') 291 Rangx=[MergeData.AX(1) MergeData.AX(end)]; 292 Rangy=[MergeData.AY(1) MergeData.AY(end)]; 282 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFileOut,FileExtOut,NomType{1},i1,i2,j1,j2); 283 284 %% recording the merged field 285 if strcmp(FileExtOut,'.png') %output as image 286 if BitDepth==8 287 imwrite(uint8(MergeData.A),OutputFile,'BitDepth',8) 293 288 else 294 Rangx=[0.5 npx-0.5]; 295 Rangy=[npy-0.5 0.5];%default 296 end 297 pxcmx=(npx-1)/(Rangx(2)-Rangx(1)); 298 pxcmy=(npy-1)/(Rangy(1)-Rangy(2)); 299 T_x=-pxcmx*Rangx(1)+0.5; 300 T_y=-pxcmy*Rangy(2)+0.5; 301 GeometryCal.focal=1; 302 GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1]; 303 GeometryCal.Tx_Ty_Tz=[T_x T_y 1]; 304 ImaDoc.GeometryCalib=GeometryCal; 289 imwrite(uint16(MergeData.A),OutputFile,'BitDepth',16) 290 end 291 if index==1 292 %write xml calibration file, using the first file 293 siz=size(MergeData.A); 294 npy=siz(1); 295 npx=siz(2); 296 if isfield(MergeData,'coord_x') && isfield(MergeData,'coord_y') 297 Rangx=MergeData.coord_x; 298 Rangy=MergeData.coord_y; 299 elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY') 300 Rangx=[MergeData.AX(1) MergeData.AX(end)]; 301 Rangy=[MergeData.AY(1) MergeData.AY(end)]; 302 else 303 Rangx=[0.5 npx-0.5]; 304 Rangy=[npy-0.5 0.5];%default 305 end 306 pxcmx=(npx-1)/(Rangx(2)-Rangx(1)); 307 pxcmy=(npy-1)/(Rangy(1)-Rangy(2)); 308 T_x=-pxcmx*Rangx(1)+0.5; 309 T_y=-pxcmy*Rangy(2)+0.5; 310 GeometryCal.CalibrationType='rescale'; 311 GeometryCal.CoordUnit=MergeData.CoordUnit; 312 GeometryCal.focal=1; 313 GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1]; 314 GeometryCal.Tx_Ty_Tz=[T_x T_y 1]; 315 ImaDoc.GeometryCalib=GeometryCal; 316 t=struct2xml(ImaDoc); 317 t=set(t,1,'name','ImaDoc'); 318 save(t,[fileparts(OutputFile) '.xml']) 319 end 320 305 321 else 306 322 MergeData.ListGlobalAttribute={'Conventions','Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'}; … … 342 358 end 343 359 error=0; 360 MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field 344 361 NbView=length(Data); 345 362 if NbView==1 346 363 return 347 364 end 348 MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field349 365 350 366 %% group the variables (fields of 'Data') in cells of variables with the same dimensions
Note: See TracChangeset
for help on using the changeset viewer.