Image processing 如何在MATLAB中读取.img图像格式?
我有.img格式的x光图像Image processing 如何在MATLAB中读取.img图像格式?,image-processing,matlab,Image Processing,Matlab,我有.img格式的x光图像 如何在MATLAB中读取.img图像格式并转换为png或其他图像格式?在x射线图像的上下文中,“.img”文件是Mayo Analyze类型图像的二进制文件。您还需要“.hdr”文件。matlab不支持这种格式,除非您有图像处理工具箱(在本例中,请查看函数) 但您也可以使用文件交换库中的函数来读取它们(我没有测试): 加载图像时请参考“.hdr”文件,而不是“.img”。在x射线图像的上下文中,“.img”文件是Mayo Analysis类型图像的二进制文件。您还需
如何在MATLAB中读取.img图像格式并转换为png或其他图像格式?在x射线图像的上下文中,“.img”文件是Mayo Analyze类型图像的二进制文件。您还需要“.hdr”文件。matlab不支持这种格式,除非您有图像处理工具箱(在本例中,请查看函数) 但您也可以使用文件交换库中的函数来读取它们(我没有测试):
加载图像时请参考“.hdr”文件,而不是“.img”。在x射线图像的上下文中,“.img”文件是Mayo Analysis类型图像的二进制文件。您还需要“.hdr”文件。matlab不支持这种格式,除非您有图像处理工具箱(在本例中,请查看函数) 但您也可以使用文件交换库中的函数来读取它们(我没有测试):
加载图像时请参考“.hdr”文件,而不是“.img”。以下代码足以回答您的问题
% 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')
matlab支持的扩展包括
'bmp' Windows® Bitmap (BMP)
1-bit, 8-bit, and 24-bit uncompressed images
'gif' Graphics Interchange Format (GIF)
8-bit images
'hdf' Hierarchical Data Format (HDF4)
8-bit raster image data sets with or without associated colormap, 24-bit raster image data sets
'jpg' or 'jpeg' Joint Photographic Experts Group (JPEG)
8-bit, 12-bit, and 16-bit Baseline JPEG images
Note: imwrite converts indexed images to RGB before writing data to JPEG files, because the JPEG format does not support indexed images.
'jp2' or 'jpx' JPEG 2000 — Joint Photographic Experts Group 2000
1-bit, 8-bit, and 16-bit JPEG 2000 images
'pbm' Portable Bitmap (PBM)
Any 1-bit PBM image, ASCII (plain) or raw (binary) encoding
'pcx' Windows Paintbrush (PCX)
8-bit images
'pgm' Portable Graymap (PGM)
Any standard PGM image; ASCII (plain) encoded with arbitrary color depth; raw (binary) encoded with up to 16 bits per gray value
'png' Portable Network Graphics (PNG)
1-bit, 2-bit, 4-bit, 8-bit, and 16-bit grayscale images; 8-bit and 16-bit grayscale images with alpha channels; 1-bit, 2-bit, 4-bit, and 8-bit indexed images; 24-bit and 48-bit truecolor images; 24-bit and 48-bit truecolor images with alpha channels
'pnm' Portable Anymap (PNM)
Any of the PPM/PGM/PBM formats, chosen automatically
'ppm' Portable Pixmap (PPM)
Any standard PPM image: ASCII (plain) encoded with arbitrary color depth or raw (binary) encoded with up to 16 bits per color component
'ras' Sun™ Raster (RAS)
Any RAS image, including 1-bit bitmap, 8-bit indexed, 24-bit truecolor, and 32-bit truecolor with alpha
'tif' or 'tiff' Tagged Image File Format (TIFF)
Baseline TIFF images, including:
1-bit, 8-bit, 16-bit, 24-bit, and 48-bit uncompressed images and images with packbits, LZW, or Deflate compression
1-bit images with CCITT 1D, Group 3, and Group 4 compression
CIELAB, ICCLAB, and CMYK images
'xwd' X Windows Dump (XWD)
8-bit ZPixmaps
以下代码足以回答您的问题
% 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')
matlab支持的扩展包括
'bmp' Windows® Bitmap (BMP)
1-bit, 8-bit, and 24-bit uncompressed images
'gif' Graphics Interchange Format (GIF)
8-bit images
'hdf' Hierarchical Data Format (HDF4)
8-bit raster image data sets with or without associated colormap, 24-bit raster image data sets
'jpg' or 'jpeg' Joint Photographic Experts Group (JPEG)
8-bit, 12-bit, and 16-bit Baseline JPEG images
Note: imwrite converts indexed images to RGB before writing data to JPEG files, because the JPEG format does not support indexed images.
'jp2' or 'jpx' JPEG 2000 — Joint Photographic Experts Group 2000
1-bit, 8-bit, and 16-bit JPEG 2000 images
'pbm' Portable Bitmap (PBM)
Any 1-bit PBM image, ASCII (plain) or raw (binary) encoding
'pcx' Windows Paintbrush (PCX)
8-bit images
'pgm' Portable Graymap (PGM)
Any standard PGM image; ASCII (plain) encoded with arbitrary color depth; raw (binary) encoded with up to 16 bits per gray value
'png' Portable Network Graphics (PNG)
1-bit, 2-bit, 4-bit, 8-bit, and 16-bit grayscale images; 8-bit and 16-bit grayscale images with alpha channels; 1-bit, 2-bit, 4-bit, and 8-bit indexed images; 24-bit and 48-bit truecolor images; 24-bit and 48-bit truecolor images with alpha channels
'pnm' Portable Anymap (PNM)
Any of the PPM/PGM/PBM formats, chosen automatically
'ppm' Portable Pixmap (PPM)
Any standard PPM image: ASCII (plain) encoded with arbitrary color depth or raw (binary) encoded with up to 16 bits per color component
'ras' Sun™ Raster (RAS)
Any RAS image, including 1-bit bitmap, 8-bit indexed, 24-bit truecolor, and 32-bit truecolor with alpha
'tif' or 'tiff' Tagged Image File Format (TIFF)
Baseline TIFF images, including:
1-bit, 8-bit, 16-bit, 24-bit, and 48-bit uncompressed images and images with packbits, LZW, or Deflate compression
1-bit images with CCITT 1D, Group 3, and Group 4 compression
CIELAB, ICCLAB, and CMYK images
'xwd' X Windows Dump (XWD)
8-bit ZPixmaps
在这种情况下,文件扩展名不能说明任何有关文件格式的信息。它可能是一个ISO磁盘映像,但这会有点奇怪。首先找出您拥有的文件类型。文件开头可能有一些神奇的数字或类似的数字,可以识别文件格式:我建议编辑你的标题,但被拒绝了。我仍然认为您应该将其更改为您所指的图像格式的更精确描述。在这种情况下,文件扩展名不能说明任何有关文件格式的信息。它可能是一个ISO磁盘映像,但这会有点奇怪。首先找出您拥有的文件类型。文件开头可能有一些神奇的数字或类似的数字,可以识别文件格式:我建议编辑你的标题,但被拒绝了。我仍然认为您应该将其更改为更精确地描述您所指的图像格式。