Reading in a 32bit tif
16 ビュー (過去 30 日間)
古いコメントを表示
Hi there,
I am trying to read in a 32bit tif image that was taken with a x ray detector. The dynamic range on this detector is huge and it saves the pixels with intensities from 0 all the way up to 11,000,000 hence the 32 bits required. The image won't display with a normal image viewing software and will appear totally black as the vast majority of pixels have low values. But if you would like to see the picture I've uploaded it here http://www.2shared.com/photo/c_ElAUtM/fix.html
What I would like to do it read in the file to an array, do a little value changing and save it again as a 32 bit tif.
So far I've got this but I get a few errors when I run it from command prompt .
any help would be very much appreciated , thanks
imgdata = imread('fix.tif');
t = Tiff('myfile9.tif','w');
tagstruct.ImageLength = size(imgdata,1)
tagstruct.ImageWidth = size(imgdata,2)
tagstruct.Photometric = Tiff.Photometric.LinearRaw
tagstruct.BitsPerSample = 32
%tagstruct.SamplesPerPixel = 1
%tagstruct.RowsPerStrip = 16
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky
tagstruct.Software = 'MATLAB'
t.setTag(tagstruct)
t.write(imgdata);
t.close();
imagesc(imread('myfile9.tif'));
0 件のコメント
採用された回答
John
2012 年 7 月 3 日
The SampleFormat for your existing TIFF is signed integer. The tiff class is erroring out because you set the SampleFormat to UInt instead. Try settting it to Tiff.SampleFormat.Int instead.
3 件のコメント
John
2012 年 7 月 3 日
Yeah, I now see that you didn't actually set the tag, in which case LibTIFF defaults to UInt , which caused the problem. I would set SampleFormat around the same place you set BitsPerSample.
You are unfortunately about to run into a problem with the photometric interpretation, however. Writing signed integer is only currently supported with either MinIsBlack or MinIsWhite (grayscale) photometric interpretations. Any reason why you picked "LinearRaw"?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!