Changeset 956 for trunk/src/series
- Timestamp:
- Jun 22, 2016, 8:10:14 PM (8 years ago)
- Location:
- trunk/src/series
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/ima2vol.m
r953 r956 46 46 ParamOut.ProjObject='on';%can use projection object(option 'off'/'on', 47 47 ParamOut.Mask='on';%can use mask option (option 'off'/'on', 'off' by default) 48 ParamOut.OutputDirExt='.v ertical_cut';%set the output dir extension48 ParamOut.OutputDirExt='.vol';%set the output dir extension 49 49 ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice 50 50 %check the input files … … 133 133 end 134 134 if jfile==1 135 vol=zeros(nbfield_j,size(Data.A,1),size(Data.A,2));136 Z=1:nbfield_j;%default Z values135 VolData.A=zeros(nbfield_j,size(Data.A,1),size(Data.A,2)); 136 VolData.Coord_z=1:nbfield_j;%default Z values 137 137 end 138 vol(jfile,:,:)=double(Data.A);%concacene along y139 Z(jfile)=Data.PlaneCoord(3);138 VolData.A(jfile,:,:)=Data.A;%concacene along y 139 VolData.Coord_z(jfile)=Data.PlaneCoord(3); 140 140 end 141 if ifile==1 142 npx=size(Data.A,2); 143 npy=size(Data.A,1); 144 npz=256; 145 ind_x=round(npx/2)-10:round(npx/2)+10;%image index at the mid x position 146 ind_y=round(npy/2)-10:round(npy/2)+10;;%image index at the mid y position 147 148 %write xml calibration file, using the first file 149 Rangx=Data.Coord_x; 150 Rangy=Data.Coord_y; 151 Rangz=[Z(end) Z(1)]; 141 % npx=size(Data.A,2); 142 % npy=size(Data.A,1); 143 % npz=256; 144 % ind_x=round(npx/2)-10:round(npx/2)+10;%image index at the mid x position 145 % ind_y=round(npy/2)-10:round(npy/2)+10;%image index at the mid y position 146 % ind_y=ind_y-100;% shift to avoid the injector 147 % %write xml calibration file, using the first file 148 % Rangx=Data.Coord_x; 149 % Rangy=Data.Coord_y; 150 % Rangz=[Z(end) Z(1)]; 151 % 152 % GeometryCal.CalibrationType='rescale'; 153 % GeometryCal.CoordUnit=Data.CoordUnit; 154 % GeometryCal.focal=1; 155 % %scaling along x, y and z 156 % pxcmx=(npx-1)/(Rangx(2)-Rangx(1)); 157 % pxcmy=(npy-1)/(Rangy(1)-Rangy(2)); 158 % pxcmz=(npz-1)/(Rangz(2)-Rangz(1)); 159 % T_x=-pxcmx*Rangx(1)+0.5; 160 % T_y=-pxcmy*Rangy(2)+0.5; 161 % T_z=-pxcmz*Rangz(2)+0.5; 162 % % xml file for x cut 163 % GeometryCal.R=[pxcmx,0,0;0,pxcmz,0;0,0,1]; 164 % GeometryCal.Tx_Ty_Tz=[T_x T_z 1]; 165 % ImaDoc.GeometryCalib=GeometryCal; 166 % t=struct2xml(ImaDoc); 167 % t=set(t,1,'name','ImaDoc'); 168 % save(t,fullfile(RootPath{1},SubdirOut,'cut_x.xml')) 169 % % xml file for y cut 170 % GeometryCal.R=[pxcmy,0,0;0,pxcmz,0;0,0,1]; 171 % GeometryCal.Tx_Ty_Tz=[T_y T_z 1]; 172 % ImaDoc.GeometryCalib=GeometryCal; 173 % t=struct2xml(ImaDoc); 174 % t=set(t,1,'name','ImaDoc'); 175 % save(t,fullfile(RootPath{1},SubdirOut,'cut_y.xml')) 176 % end 152 177 153 GeometryCal.CalibrationType='rescale'; 154 GeometryCal.CoordUnit=Data.CoordUnit; 155 GeometryCal.focal=1; 156 %scaling along x, y and z 157 pxcmx=(npx-1)/(Rangx(2)-Rangx(1)); 158 pxcmy=(npy-1)/(Rangy(1)-Rangy(2)); 159 pxcmz=(npz-1)/(Rangz(2)-Rangz(1)); 160 T_x=-pxcmx*Rangx(1)+0.5; 161 T_y=-pxcmy*Rangy(2)+0.5; 162 T_z=-pxcmz*Rangz(2)+0.5; 163 % xml file for x cut 164 GeometryCal.R=[pxcmx,0,0;0,pxcmz,0;0,0,1]; 165 GeometryCal.Tx_Ty_Tz=[T_x T_z 1]; 166 ImaDoc.GeometryCalib=GeometryCal; 167 t=struct2xml(ImaDoc); 168 t=set(t,1,'name','ImaDoc'); 169 save(t,fullfile(RootPath{1},SubdirOut,'cut_x.xml')) 170 % xml file for y cut 171 GeometryCal.R=[pxcmy,0,0;0,pxcmz,0;0,0,1]; 172 GeometryCal.Tx_Ty_Tz=[T_y T_z 1]; 173 ImaDoc.GeometryCalib=GeometryCal; 174 t=struct2xml(ImaDoc); 175 t=set(t,1,'name','ImaDoc'); 176 save(t,fullfile(RootPath{1},SubdirOut,'cut_y.xml')) 177 end 178 cut_y=squeeze(mean(vol(:,:,ind_x),3)); 179 cut_y=interp1(Z,cut_y,linspace(Z(1),Z(end),npz)); 180 cut_x=squeeze(mean(vol(:,ind_y,:),2)); 181 cut_x=interp1(Z,cut_x,linspace(Z(1),Z(end),npz)); 182 183 filename_x=fullfile_uvmat(RootPath{1},SubdirOut,'cut_x','.png','_1',i1_series{1}(jfile,ifile),[],j1); 184 filename_y=fullfile_uvmat(RootPath{1},SubdirOut,'cut_y','.png','_1',i1_series{1}(jfile,ifile),[],j1); 185 % filename_new=name_generator(basename_new,num_i,1,'.vol','_i'); 186 imwrite(uint8(vol),filename_x,'png','BitDepth',8)% 187 display([filename_x 'written (8bits image)']) 188 imwrite(uint8(vol),filename_y,'png','BitDepth',8)% 189 display([filename_y 'written (8bits image)']) 178 filename=fullfile_uvmat(RootPath{1},SubdirOut,RootFile{1},'.nc','_1',i1_series{1}(jfile,ifile),[],j1); 179 VolData.ListVarName={'Coord_z','Coord_y','Coord_x','A'}; 180 VolData.VarDimName={'Coord_z','Coord_y','Coord_x',{'Coord_z','Coord_y','Coord_x'}}; 181 VolData.Coord_x=Data.Coord_x; 182 VolData.Coord_y=Data.Coord_y; 183 struct2nc(filename,VolData) 184 disp([filename ' written']) 190 185 end 191 186 -
trunk/src/series/merge_proj.m
r955 r956 203 203 if min(cell2mat(CheckImage))==1 && (~Param.CheckObject || strcmp(Param.ProjObject.Type,'plane')) 204 204 FileExtOut='.png'; %image output (input and proj result = image) 205 for iview=1:NbView206 BitDepth(iview)=FileInfo{iview}.BitDepth;207 end208 BitDepth=max(BitDepth);209 205 else 210 206 FileExtOut='.nc'; %netcdf output … … 357 353 %% recording the merged field 358 354 if strcmp(FileExtOut,'.png') %output as image 359 if BitDepth==8360 imwrite(uint8(MergeData.A),OutputFile,'BitDepth',8)361 else362 imwrite(uint16(MergeData.A),OutputFile,'BitDepth',16)363 end364 355 if index==1 356 if strcmp(class(MergeData.A),'uint8') 357 BitDepth=8; 358 else 359 BitDepth=16; 360 end 365 361 %write xml calibration file, using the first file 366 362 siz=size(MergeData.A); … … 391 387 save(t,[fileparts(OutputFile) '.xml']) 392 388 end 393 389 if BitDepth==8 390 imwrite(uint8(MergeData.A),OutputFile,'BitDepth',8) 391 else 392 imwrite(uint16(MergeData.A),OutputFile,'BitDepth',16) 393 end 394 394 else %output as netcdf files 395 395 MergeData.ListGlobalAttribute={'Conventions','Project','InputFile_1','InputFile_end','NbCoord','NbDim'};
Note: See TracChangeset
for help on using the changeset viewer.