Read Tif File shows Error "Cannot handle different values per sample for "BitsPerSample"."

1 回表示 (過去 30 日間)
Jihang Wang
Jihang Wang 2020 年 3 月 11 日
回答済み: Rishik Ramena 2020 年 12 月 29 日
I have a tif file that I can view it from Windows Photos App. You can download it from this link.
I tried to load it to Matlab using `imread` function, however it shows an error below.
TIFF library error - 'TIFFReadDirectory: Cannot handle different values per sample for "BitsPerSample".'
I then further looking into the file's profile and find that the BitDepth and BitsPerSample value seems not correct. Also, the MaxSample value looks weird.
By checking the Matlab buildin tiff file profile, I learned that for a RGB image, BitDepth should be 24 and BitsPerSample should be [8,8,8]. However, when I tried to explicitly change them, I still get the same error.
fname = 'TifImg.tif';
info = imfinfo(fname);
% Explicitly Assign Correct Value to BitDepth and BitsPerSample (still doesn't work)
for i = 1: length(info)
info(i).BitDepth = 24;
info(i).BitsPerSample = [8 8 8];
end
% Read Tif Image
frame = imread(fname, 1, 'Info', info);
imshow(frame,[])
I hope someone can help me to load this image to Matlab and point me which profile I should change to successfully load the file.

回答 (1 件)

Rishik Ramena
Rishik Ramena 2020 年 12 月 29 日
I hope the workaround mentioned here worked.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by