flipper.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. function flipper()
  2. % written by: DLB 2/28/07
  3. % sick of all this WB z-flipping crap. thank goodness this program is
  4. % already obsolete!!!
  5. clear all;
  6. s = pwd;
  7. cd C:\Data
  8. [filename, pathname] = uigetfile({'*.img';'*.*'},'File Selector');
  9. if isequal(filename,0)
  10. disp('User selected Cancel')
  11. else
  12. disp(['User selected', fullfile(pathname, filename)])
  13. end
  14. dat = fread(fopen([pathname filename],'r','ieee-be'),inf,'float');
  15. a = size(dat)/128/128;
  16. zdim = a(1);
  17. data = reshape(dat,128,128,zdim);
  18. if zdim == 239
  19. chunk1 = data(:,:,1:1:34);
  20. chunk2 = data(:,:,35:1:68);
  21. chunk3 = data(:,:,69:102);
  22. chunk4 = data(:,:,103:1:136);
  23. chunk5 = data(:,:,137:1:170);
  24. chunk6 = data(:,:,171:1:204);
  25. chunk7 = data(:,:,205:1:239);
  26. A(:,:,1:1:35) = chunk7(:,:,1:1:35);
  27. A(:,:,36:1:69) = chunk6(:,:,1:1:34);
  28. A(:,:,70:1:103) = chunk5(:,:,1:1:34);
  29. A(:,:,104:1:137) = chunk4(:,:,1:1:34);
  30. A(:,:,138:1:171) = chunk3(:,:,1:1:34);
  31. A(:,:,172:1:205) = chunk2(:,:,1:1:34);
  32. A(:,:,206:1:239) = chunk1(:,:,1:1:34);
  33. output = A;
  34. end
  35. if zdim == 171
  36. chunk1 = data(:,:,1:1:34);
  37. chunk2 = data(:,:,35:1:68);
  38. chunk3 = data(:,:,69:102);
  39. chunk4 = data(:,:,103:1:136);
  40. chunk5 = data(:,:,137:1:171);
  41. A(:,:,1:1:35) = chunk5(:,:,1:1:35);
  42. A(:,:,36:1:69) = chunk4(:,:,1:1:34);
  43. A(:,:,70:1:103) = chunk3(:,:,1:1:34);
  44. A(:,:,104:1:137) = chunk2(:,:,1:1:34);
  45. A(:,:,138:1:171) = chunk1(:,:,1:1:34);
  46. output = A;
  47. end
  48. if zdim == 136
  49. chunk1 = data(:,:,1:1:34);
  50. chunk2 = data(:,:,35:1:68);
  51. chunk3 = data(:,:,69:102);
  52. chunk4 = data(:,:,103:1:136);
  53. A(:,:,1:1:34) = chunk4(:,:,1:1:34);
  54. A(:,:,35:1:68) = chunk3(:,:,1:1:34);
  55. A(:,:,69:1:102) = chunk2(:,:,1:1:34);
  56. A(:,:,103:1:136) = chunk1(:,:,1:1:34);
  57. output = A;
  58. end
  59. fid = fopen([pathname filename '.Z-FLIPPED'],'w','ieee-be');
  60. fwrite(fid,output,'float');
  61. fclose all;