필터 지우기
필터 지우기

Reading in a 32bit tif

조회 수: 15 (최근 30일)
Jon
Jon 2012년 7월 3일
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'));

채택된 답변

John
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
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"?
Jon
Jon 2012년 7월 4일
Hi John
I had no reason for picking LinearRaw but I am now on MinIsBlack instead. Thanks for that suggestion.
Also the other suggestion that you made worked . I found I had to put the t.setTag('SampleFormat', Tiff.SampleFormat.Int); line of code just after the t.setTag(tagstruct).
You have been most helpful, lots of positive karma for you.
Thanks very much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by