【问题标题】:Matlab only opens first frame of multi-page tiff stackMatlab 只打开多页 tiff 堆栈的第一帧
【发布时间】:2013-11-29 13:18:25
【问题描述】:

我在 ImageJ 中创建了带有宏的多页 tiff 文件,我现在正尝试使用 matlab 打开它,但我只能访问第一帧。

这是 imfinfo(filename) 的结果。因此,我得到 ​​p>

length(imfinfo(filename)) = 1

Filename: [1x129 char]
              FileModDate: '28-nov-2013 12:27:51'
                 FileSize: 6.7905e+09
                   Format: 'tif'
            FormatVersion: []
                    Width: 512
                   Height: 512
                 BitDepth: 8
                ColorType: 'grayscale'
          FormatSignature: [77 77 0 42]
                ByteOrder: 'big-endian'
           NewSubFileType: 0
            BitsPerSample: 8
              Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
             StripOffsets: 932625
          SamplesPerPixel: 1
             RowsPerStrip: 512
          StripByteCounts: 262144
              XResolution: []
              YResolution: []
           ResolutionUnit: 'None'
                 Colormap: []
      PlanarConfiguration: 'Chunky'
                TileWidth: []
               TileLength: []
              TileOffsets: []
           TileByteCounts: []
              Orientation: 1
                FillOrder: 1
         GrayResponseUnit: 0.0100
           MaxSampleValue: 255
           MinSampleValue: 0
             Thresholding: 1
                   Offset: 8
         ImageDescription: 'ImageJ=1.47q
 images=25900
 slices=25900
 loop=false

但是,如果我在 ImageJ 中打开相同的 tif 文件,那么我可以读取并滚动 25900 帧……奇怪的是,matlab 可以读取我在 imageJ 中创建的以前的多页 tiff,而无需我的批处理宏……

我不明白发生了什么...任何帮助将不胜感激! 谢谢, 史蒂文

【问题讨论】:

    标签: matlab tiff imagej


    【解决方案1】:

    这其实是ImageJ 的错。对于大型 TIFF,而不是使用 BigTiff 标准来保存堆栈,ImageJ 而是使用包含第一帧的假 TIFF 标头保存原始文件,并愉快地将其命名为 .tif。您可以与 ImageJ 开发人员讨论为什么他们认为这是一个好主意。

    要将这些堆栈读入 Matlab,您可以使用 memmapfileMappedTensor

    【讨论】:

    【解决方案2】:

    您必须遍历堆栈中的所有图像:

    fname = 'my_file_with_lots_of_images.tif';
    info = imfinfo(fname);
    imageStack = [];
    numberOfImages = length(info);
    for k = 1:numberOfImages
        currentImage = imread(fname, k, 'Info', info);
        imageStack(:,:,k) = currentImage;
    end 
    

    【讨论】:

    • 感谢您的评论,但我已经这样做了。我实际上已经意识到这个错误是由于 tiff 堆栈的大小过大:每当它大于大约 5 Gb 时,Matlab 只会看到第一帧,但如果我通过拆分文件来减小大小,那么它就可以工作......很烦人,因为我不得不重写脚本,但我没有找到任何其他解决方案......
    • 如果正确预分配imageStac,这个过程会快很多。甚至 MATLAB 编辑器也会警告您在循环中增加矩阵的大小。
    猜你喜欢
    • 2016-04-11
    • 1970-01-01
    • 1970-01-01
    • 2017-03-30
    • 2022-01-17
    • 1970-01-01
    • 2013-12-12
    • 1970-01-01
    • 2013-09-17
    相关资源
    最近更新 更多