123456789101112131415161718192021222324 |
- function amiraWriter(data,filename,dx,dy,dz,M,N,P,FOV,zFOV)
- fid = fopen([filename],'w');
- fprintf(fid,'# AmiraMesh 3D BINARY 2.0\n\n');
- fprintf(fid,['# CreationDate: ' datestr(now,'ddd mmm') datestr(now,' dd HH:MM:SS yyyy') '\n\n']);
- fprintf(fid,'define Lattice %g %g %g\n\n',M,N,P);
- fprintf(fid,'Parameters {\n');
- fprintf(fid,' Content "%gx%gx%g %s, uniform coordinates",',M,N,P,'float');
- fprintf(fid,' BoundingBox %g %g %g %g %g %g,\n',(50-FOV)/2+dx/2,50-(50-FOV)/2-dx/2,(50-FOV)/2+dy/2,50-(50-FOV)/2-dy/2,0,zFOV-dz);
- % fprintf(fid,' BoundingBox %g %g %g %g %g %g,\n',0,FOV-dx,0,FOV-dy,0,zFOV-dz);
- fprintf(fid,' CoordType "uniform"\n');
- fprintf(fid,'}\n\n');
- fprintf(fid,'Lattice { %s Data } @1\n\n','float');
- fprintf(fid,'# Data section follows\n');
- fprintf(fid,'@1\n');
- fclose(fid); % close the text part of the file
-
- % write the data in big endian format
- fid = fopen([filename],'ab','ieee-be');
- fwrite(fid,data(:,:,:),'float');
- fclose(fid);
|