【问题标题】:Matlab 'rtifc' error when reading .tif files读取 .tif 文件时出现 Matlab 'rtifc' 错误
【发布时间】:2015-03-12 00:27:44
【问题描述】:

我似乎在读取 Matlab2014a 上的 .tif 文件时遇到问题。每当我使用 imread 函数读取图像时,都会得到以下输出:

Error using rtifc
TIFF library error - 'TIFFReadDirectory:  Incorrect count for   "SampleFormat".'

Error in readtif (line 48)
[X, map, details] = rtifc(args);

Error in imread (line 415)
[X, map] = feval(fmt_s.read, filename, extraArgs{:});

Error in circles (line 3)
RGB = imread('C:\users\michael\desktop\inkblob12.tif');

我不知道问题是什么或如何解决它,所以任何指针将不胜感激!非常感谢。

编辑:这是信息信息输出:

 Filename: 'C:\users\michael\desktop\inkblob12.tif'
              FileModDate: '10-Mar-2015 14:06:40'
                 FileSize: 159794
                   Format: 'tif'
            FormatVersion: []
                    Width: 250
                   Height: 250
                 BitDepth: 32
                ColorType: 'truecolor'
          FormatSignature: [73 73 42 0]
                ByteOrder: 'little-endian'
           NewSubFileType: 0
            BitsPerSample: [8 8 8 8]
              Compression: 'LZW'
PhotometricInterpretation: 'RGB'
             StripOffsets: [1x21 double]
          SamplesPerPixel: 4
             RowsPerStrip: 12
          StripByteCounts: [1x21 double]
              XResolution: 72.0090
              YResolution: 72.0090
           ResolutionUnit: 'Inch'
                 Colormap: []
      PlanarConfiguration: 'Chunky'
                TileWidth: []
               TileLength: []
              TileOffsets: []
           TileByteCounts: []
              Orientation: 1
                FillOrder: 1
         GrayResponseUnit: 0.0100
           MaxSampleValue: [255 255 255 255]
           MinSampleValue: [0 0 0 0]
             Thresholding: 1
                   Offset: 159126
                 Software: 'Matrox Imaging Library [9.00]                                          ...'
                Predictor: 'Horizontal differencing'
             ExtraSamples: 2
             SampleFormat: {'Unsigned integer'  'Unsigned integer'  'Unsigned integer'}

【问题讨论】:

  • 您正在阅读的文件是否已损坏/格式不正确?您是否尝试过任何其他 TIFF 文件?
  • @scai 基本上我有一些 1000x944 .tif 图像可以在 matlab 中阅读,但我在绘画中打开这些图像,获取 250x250 的“块”并将它们保存为新的 .tif 文件。我无法打开任何这些新文件,但我不明白为什么会出现问题。
  • 我也没有 - 我只是通过在绘图中打开一个文件进行检查,将其保存为 .tif,而 2013b 上的 imread 至少可以很好地处理它。您能否编辑问题以显示 imfinfo 为问题文件之一返回的内容?
  • @nkjt 这很烦人,因为我刚刚制作了 165 张这些新图像进行测试!当然,我会在大约半小时内编辑它——我现在正远离我的电脑。谢谢!
  • 也许this 会有所帮助。

标签: matlab


【解决方案1】:

具体问题似乎是因为SampleFormat 的标记不是所使用的 tiff 库可以处理的类型。我建议您检查问题是否已从您的原始工作 tif 以某种方式更改为您的裁剪图像。 (您可能还想尝试只使用imcrop 或其他东西来直接在 MATLAB 中制作缩小图像,从而完全避免潜在的不兼容问题。

由于标签的内容似乎真的只是'Unsigned integer',因此可以通过 MATLAB 使用通往 LibTiff 库例程的网关简单地强制重新标记所有图像以匹配 MATLAB 的期望:

t = Tiff('inkblob12.tif','a'); % loop over your file names, if this works
t.setTag('SampleFormat',Tiff.SampleFormat.UInt);
t.close();

a for append 应该保留已经存在的任何内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-03
    • 2016-10-26
    相关资源
    最近更新 更多