matlab imshow不使用某些tiff文件

时间:2013-11-10 14:53:59

标签: matlab tiff imshow

尝试使用某些tiff文件运行imshow时出现以下错误:

??? Error using ==> imageDisplayValidateParams>validateCData at 114
Unsupported dimension

Error in ==> imageDisplayValidateParams at 31
common_args.CData = validateCData(common_args.CData,image_type);

Error in ==> imageDisplayParseInputs at 79
common_args = imageDisplayValidateParams(common_args);

Error in ==> imshow at 199
  [common_args,specific_args] = ...

Error in ==> CellArea at 6
imshow('A1 x20.tiff')

我最初使用imread将图像数据存储在matlab变量中,当它与imshow不起作用时,我用它来直接用文件名获取图像;错误信息是相同的。

我想分析的问题图片是1032x778个tiff文件。我使用Paint制作了一个样本tif图像,该函数没有任何问题。有谁知道导致这些错误的原因以及如何显示图像?感谢

以下是其中一张图片的信息输出

                 Filename: 'A1 x20.tiff'
              FileModDate: '14-Oct-2013 15:49:26'
                 FileSize: 3211714
                   Format: 'tif'
            FormatVersion: []
                    Width: 1032
                   Height: 778
                 BitDepth: 32
                ColorType: 'truecolor'
          FormatSignature: [73 73 42 0]
                ByteOrder: 'little-endian'
           NewSubFileType: 0
            BitsPerSample: [8 8 8 8]
              Compression: 'Uncompressed'
PhotometricInterpretation: 'RGB'
             StripOffsets: 8
          SamplesPerPixel: 4
             RowsPerStrip: 4.2950e+009
          StripByteCounts: 3211584
              XResolution: []
              YResolution: []
           ResolutionUnit: 'None'
                 Colormap: []
      PlanarConfiguration: 'Chunky'
                TileWidth: []
               TileLength: []
              TileOffsets: []
           TileByteCounts: []
              Orientation: 1
                FillOrder: 1
         GrayResponseUnit: 0.0100
           MaxSampleValue: [255 255 255 255]
           MinSampleValue: 0
             Thresholding: 1
                   Offset: 3211592

做x = imread('A1 x20.tiff'),然后x给出

Name x
Size 778x1032x4
Bytes 3211584
Class uint8
Attributes

1 个答案:

答案 0 :(得分:4)

由于某种原因,您的tiff文件有四个通道(与多个帧无关):size(x,3)==4。我猜第四个是alpha通道 imshow可以显示灰度图像,索引图像(带size(x,3)==1)或真彩色图像(带size(x,3)==3)。您的图片有4个频道,因此imshow失败 要求inshow仅在前三个频道上工作,这就是诀窍:

 >> imshow( x(:,:,1:3) );