4

.tif各ピクセル値(単一チャネル)が浮動小数点である画像があります。とにかくmatlab(imread)でそれを読み取り、何らかの操作を行って浮動小数点に書き戻すことはできますか?

私がそうするならば、imwrite(I,'img.tif')それは8ビットの単一チャネル(0 ... 255)に変換されます

このサンプルはmathworksでのみ見つかりました:

info = imfinfo(filename); 
t = Tiff(filename, 'w'); 
tagstruct.ImageLength = size(timg, 1); 
tagstruct.ImageWidth = size(timg, 2); 
tagstruct.Compression = Tiff.Compression.None; 
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP; 
tagstruct.Photometric = Tiff.Photometric.MinIsBlack; 
tagstruct.BitsPerSample = info.BitsPerSample; % 32; 
tagstruct.SamplesPerPixel = info.SamplesPerPixel; % 1; 
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky; 
t.setTag(tagstruct); 
t.write(timg); 
t.close();

Imfinfo:

   info = 

                 Filename: [1x110 char]
              FileModDate: '04-dic-2012 12:02:07'
                 FileSize: 45720930
                   Format: 'tif'
            FormatVersion: []
                    Width: 2724
                   Height: 4193
                 BitDepth: 32
                ColorType: 'grayscale'
          FormatSignature: [73 73 42 0]
                ByteOrder: 'little-endian'
           NewSubFileType: 0
            BitsPerSample: 32
              Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
             StripOffsets: [4193x1 double]
          SamplesPerPixel: 1
             RowsPerStrip: 1
          StripByteCounts: [4193x1 double]
              XResolution: 100
              YResolution: 100
           ResolutionUnit: 'None'
                 Colormap: []
      PlanarConfiguration: 'Chunky'
                TileWidth: []
               TileLength: []
              TileOffsets: []
           TileByteCounts: []
              Orientation: 1
                FillOrder: 1
         GrayResponseUnit: 0.0100
           MaxSampleValue: 4.2950e+09
           MinSampleValue: 0
             Thresholding: 1
                   Offset: 45720696
             SampleFormat: 'IEEE floating point'
       ModelPixelScaleTag: [3x1 double]
         ModelTiepointTag: [6x1 double]
       GeoKeyDirectoryTag: [52x1 double]
       GeoDoubleParamsTag: [3x1 double]
4

1 に答える 1

3

フロートを含む.tifを読み取り、操作して、再度書き出す場合は、コード例が適切に機能するはずです。読み取ったファイルと画像操作を追加するだけで、うまく機能するはずです。

img = imread(in_filename)
timg = 2*timg;
info = imfinfo(in_filename); 

t = Tiff(out_filename, 'w'); 
tagstruct.ImageLength = size(timg, 1); 
tagstruct.ImageWidth = size(timg, 2); 
tagstruct.Compression = Tiff.Compression.None; 
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP; 
tagstruct.Photometric = Tiff.Photometric.MinIsBlack; 
tagstruct.BitsPerSample = info.BitsPerSample; % 32; 
tagstruct.SamplesPerPixel = info.SamplesPerPixel; % 1; 
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky; 
t.setTag(tagstruct); 
t.write(timg); 
t.close();
于 2012-12-08T13:44:58.843 に答える