如何在MATLAB中读取.img图像格式?

时间:2014-02-28 20:25:41

标签: image-processing matlab

我有.img格式的xray图像。

如何在MATLAB中读取.img图像格式并转换为png或其他图像格式?

2 个答案:

答案 0 :(得分:4)

在X射线图像的上下文中,'。img'文件是Mayo Analyze类型图像的二进制文件。你也需要'.hdr'文件。除非您拥有图像处理工具箱(在本例中查看analyze75read函数),否则matlab本身不支持此格式。

但您也可以使用文件交换库中的函数来读取它们(未经我测试):

http://www.mathworks.com/matlabcentral/fileexchange/1878-mri-analyze-tools

加载图片时请参阅'.hdr'文件,而不是'.img'。

答案 1 :(得分:0)

以下代码足以满足您的提问。

\

matlab支持的扩展名

% the .img file is opened
f = fopen('image.img')
% the f variable is read as an image with the uint8 datatype
image = fread(f, [256 378], '*uint8');
% show the image
imshow(image,[])
% write the image with the your extension choose
imwrite(image, 'filename.extension', 'extension')