MATLAB中图像的类型、大小和尺寸

3

如何在MATLAB中获取图像的类型、大小和尺寸?


我有这张图片并且想要检索它的属性。 - Achraf
2个回答

11

IMFINFO可以展示您所寻找的信息。

这是来自MATLAB帮助的示例:

info = imfinfo('ngc6543a.jpg')

info = 

       Filename: [1x95 char]
    FileModDate: '01-Oct-1996 17:19:44'
       FileSize: 27387
         Format: 'jpg'
  FormatVersion: ''
          Width: 600
         Height: 650
       BitDepth: 24
      ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
   CodingMethod: 'Huffman'
  CodingProcess: 'Sequential'
        Comment: {[1x69 char]}

是的,我想获取图像的类型、大小、尺寸,并在静态文本中显示它。 - Achraf
这就是函数IMFINFO返回的内容。点击链接查看输出的详细信息。 - Jonas

1
你可以使用imfinfo获取有关图像文件的信息,它会输出一个包含各种字段(包括宽度、高度和颜色类型)的结构体。
例如:
InfoImage = imfinfo('peppers.png');
InfoImage = 
                  Filename: '/Applications/MATLAB_R2014a.app/toolbox/matlab/imagesc...'
               FileModDate: '02-Apr-2013 15:55:52'
                  FileSize: 287677
                    Format: 'png'
             FormatVersion: []
                     Width: 512
                    Height: 384
                  BitDepth: 24
                 ColorType: 'truecolor'
           FormatSignature: [137 80 78 71 13 10 26 10]
                  Colormap: []
                 Histogram: []
             InterlaceType: 'none'
              Transparency: 'none'
    SimpleTransparencyData: []
           BackgroundColor: []
           RenderingIntent: []
            Chromaticities: []
                     Gamma: []
               XResolution: []
               YResolution: []
            ResolutionUnit: []
                   XOffset: []
                   YOffset: []
                OffsetUnit: []
           SignificantBits: []
              ImageModTime: '16 Jul 2002 16:46:41 +0000'
                     Title: []
                    Author: []
               Description: 'Zesty peppers'
                 Copyright: 'Copyright The MathWorks, Inc.'
              CreationTime: []
                  Software: []
                Disclaimer: []
                   Warning: []
                    Source: []
                   Comment: []
                 OtherText: []

然后,您可以通过常规结构分配获取所需的信息:
With = InfoImage.Width;
Height = InfoImage.Height;
Colortype = InfoImage.ColorType;

之后你就可以开始了。通过将文本框的“String”属性设置为所需内容,您可以在文本框中显示此信息:
set(handles.WidthTextbox,'String',num2str(InfoImage.Width));
and so on for the other fields.

请查看更多这里

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接