MATLAB中图像的类型,大小,尺寸

时间:2010-05-29 19:33:02

标签: matlab image-processing

如何在MATLAB中检索图像的类型,大小和尺寸?

2 个答案:

答案 0 :(得分: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]}

答案 1 :(得分: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.

查看更多HERE