1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- function flipper()
- % written by: DLB 2/28/07
- % sick of all this WB z-flipping crap. thank goodness this program is
- % already obsolete!!!
- clear all;
- s = pwd;
- cd C:\Data
- [filename, pathname] = uigetfile({'*.img';'*.*'},'File Selector');
- if isequal(filename,0)
- disp('User selected Cancel')
- else
- disp(['User selected', fullfile(pathname, filename)])
- end
- dat = fread(fopen([pathname filename],'r','ieee-be'),inf,'float');
- a = size(dat)/128/128;
- zdim = a(1);
- data = reshape(dat,128,128,zdim);
- if zdim == 239
- chunk1 = data(:,:,1:1:34);
- chunk2 = data(:,:,35:1:68);
- chunk3 = data(:,:,69:102);
- chunk4 = data(:,:,103:1:136);
- chunk5 = data(:,:,137:1:170);
- chunk6 = data(:,:,171:1:204);
- chunk7 = data(:,:,205:1:239);
- A(:,:,1:1:35) = chunk7(:,:,1:1:35);
- A(:,:,36:1:69) = chunk6(:,:,1:1:34);
- A(:,:,70:1:103) = chunk5(:,:,1:1:34);
- A(:,:,104:1:137) = chunk4(:,:,1:1:34);
- A(:,:,138:1:171) = chunk3(:,:,1:1:34);
- A(:,:,172:1:205) = chunk2(:,:,1:1:34);
- A(:,:,206:1:239) = chunk1(:,:,1:1:34);
- output = A;
- end
- if zdim == 171
- chunk1 = data(:,:,1:1:34);
- chunk2 = data(:,:,35:1:68);
- chunk3 = data(:,:,69:102);
- chunk4 = data(:,:,103:1:136);
- chunk5 = data(:,:,137:1:171);
- A(:,:,1:1:35) = chunk5(:,:,1:1:35);
- A(:,:,36:1:69) = chunk4(:,:,1:1:34);
- A(:,:,70:1:103) = chunk3(:,:,1:1:34);
- A(:,:,104:1:137) = chunk2(:,:,1:1:34);
- A(:,:,138:1:171) = chunk1(:,:,1:1:34);
- output = A;
- end
- if zdim == 136
- chunk1 = data(:,:,1:1:34);
- chunk2 = data(:,:,35:1:68);
- chunk3 = data(:,:,69:102);
- chunk4 = data(:,:,103:1:136);
- A(:,:,1:1:34) = chunk4(:,:,1:1:34);
- A(:,:,35:1:68) = chunk3(:,:,1:1:34);
- A(:,:,69:1:102) = chunk2(:,:,1:1:34);
- A(:,:,103:1:136) = chunk1(:,:,1:1:34);
- output = A;
- end
- fid = fopen([pathname filename '.Z-FLIPPED'],'w','ieee-be');
- fwrite(fid,output,'float');
- fclose all;
|