X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=utilities_LW%2FCreateSphere3D.m;fp=utilities_LW%2FCreateSphere3D.m;h=32c0bce55cc3ee13b7f83571ef20005adf7a9b08;hb=d0401c49b6b7511cfdaa0534b78bd3c5b2b0637a;hp=0000000000000000000000000000000000000000;hpb=f8358f5ec65f099f3080043580ef861c3fd3ba2e;p=CreaPhase.git diff --git a/utilities_LW/CreateSphere3D.m b/utilities_LW/CreateSphere3D.m new file mode 100644 index 0000000..32c0bce --- /dev/null +++ b/utilities_LW/CreateSphere3D.m @@ -0,0 +1,41 @@ +%%%%%%%%%%%%%%%% +%%% Function that creates a 3D matrix (size dimx, dimy, dimz) containing a sphere, centered at (cx, +%%% cy, cz), of radius r +%%% Loriane, oct 2014 +%c=128 +%r=40 +%%%%%%%%%%%%%%%% + + +r=70 +cx=200; +cy=cx; +cz=50; +dimx=400; +dimy=dimx; +dimz=100; +coeff=9.917*10^-7; % mu ou autre + +Sphere=zeros(dimx, dimy, dimz); + +for(i=1:dimx) + for(j=1:dimy) + for(k=1:dimz) + if((i-cx)^2+(j-cy)^2+(k-cz)^2 <= r^2) + Sphere(i,j,k)=1; + end + end + end +end + + +Sphere=Sphere*coeff; +name='sphere_phase_Mg_19keV' + +fid=fopen(strcat(name, '.raw'), 'w') +fwrite(fid, Sphere, 'float32'); +fclose(fid); + +cmd = ['/data/id19/bones01/bones/program/linux_debian/bin/rawtomhd filein=', strcat(name, '.raw'), ' fileout=', strcat(name, '.mhd'), ' dimx=', num2str(dimx), ' dimy=', num2str(dimy), ' dimz=', num2str(dimz), ' format=FLOAT']; +unix(cmd) +