uint16からint16ヘ変換
17 views (last 30 days)
Show older comments
以下のコードにてdicom画像をuint16からint16に変換をするのですが、uint16で値が0 のセルがint16に変換すると-32768になります。値が0のままではなくこの値になるのはなぜですか?
a=dicomread 'a.dcm'
im2int16(a)
3 Comments
Accepted Answer
Atsushi Ueno
on 31 Oct 2022
画像変換の場合、値を維持する型変換(cast関数相当)でも、ビット配列を維持する型変換(typecast関数相当)でも期待通りの変換が出来ません。例えばuint16型で最も暗い黒は値が0の時であるのに対し、int16型の0は灰色(中間の輝度)になるので、-32768だけオフセットしないと望みの変換にならないんですね。当該変換を実現するのがim2int16関数なんですね。
- uint16型:(輝度暗い) 0 ⇒ 1 ⇒ 32767 ⇒ 32768 ⇒ 32769 ⇒ 65534 ⇒ 65535 (輝度明るい)
- int16型:(輝度暗い) -32768 ⇒ -32767 ⇒ -1 ⇒ 0 ⇒ 1 ⇒ 32766 ⇒ 32767 (輝度明るい)
0 Comments
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!