您的位置:首页 > 其它

将dicom的ct值归一到(0,255)

2015-12-09 16:25 176 查看
function status = dicom2bmp(infilename)

I=dicomread(infilename);   %读取图像

metadata=dicominfo(infilename); %存储信息

lop=length(metadata.WindowCenter);%查看窗位数量

if(lop~=length(metadata.WindowWidth))%与窗位数量是否一致

    error('this is an error');

end

for i=1:lop

    center=metadata.WindowCenter(i)/metadata.RescaleSlope - metadata.RescaleIntercept;%处理窗位数值,这个地方的处理很关键

    width=metadata.WindowWidth(i)/metadata.RescaleSlope - metadata.RescaleIntercept;%处理窗宽数值,这个地方的处理很关键

    M=mat2gray(I,[center-(width/2),center+(width/2)]);%归一化

    a=strcat(infilename,num2str(i));

    a=strcat(a,'.bmp');%输出文件名的操作

     imwrite(M,a,'bmp');%输出为文件

     subplot(1,lop,i),imshow(a),title(a);%显示

End
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: