帮同学做的把T1图像转成TXT格式用于unity 3d输入的小工具

话说unity 3d好像很好玩的样子:)可怜


%Name:Img2txt
%Function:将img文件读取并转换为一列扫描格式的txt文件(用于unity输入)
%Author:Changle Zhang, zhangchanglehit@163.com
clc;clear all;close all;
[hdr,filetype,fileprefix,machine] = load_nii_hdr('20150725_192944MPRAGE26s013a1001.hdr');
[img,hdr] = load_nii_img(hdr,filetype,fileprefix,machine);

imgsize=size(img);
savemat=zeros(imgsize(1)*imgsize(2)*imgsize(3),1);
counter=1;
for i=1:imgsize(1) for j=1:imgsize(2) for k=1:imgsize(3) savemat(counter,1)=img(i,j,k); counter=counter+1; end end
end

save T1img.txt -ascii savemat 

文章来源: zclhit.blog.csdn.net,作者:zclhit_,版权归原作者所有,如需转载,请联系作者。

原文链接:zclhit.blog.csdn.net/article/details/51547293

(完)