How to convert unsigned integer 16 bit to decimal number

Hi,
what is the difference between unsigned integer 16 bit
How can I convert uint16 to decimal number in matlab?
Thanks Jim

답변 (3개)

Jan
Jan 2013년 5월 26일
The meaning of the type UINT16 is explained in:
help uint16
doc uint16
While UINT16 variables can contain integer values between 0 and 2^16-1, they are displayed as decimal numbers as doubles, singles and the other integer types also. Binary or octal numbers would be non-decimal.
the cyclist
the cyclist 2013년 5월 25일
편집: the cyclist 2013년 5월 25일
A uint16 is a 16-bit unsigned integer. You can read lots and lots of details about data types in MATLAB on this page: http://www.mathworks.com/help/matlab/data-types_data-types.html.
The default data type for most MATLAB calculations is "double", a double-precision real number. To convert a uint16 to a double:
x = double(xu16)

댓글 수: 4

The above is a way of being explicit about what datatype you will end up in. If you just want to convert it to a floating point type and you don't care so much about it being made clear that it is double you are converting to, then
x = xu16 + 0;
will do the job. It happens to convert to double as well, but that is not as obvious.
Hi,
Thanks for your reply. what is the need of adding zero to uint16. what exactly going on in this operation
Thanks jim
@Jim, I think Walter had in mind that doing this operation would add zero to the 16-bit unsigned integer variable xu16, but would also convert x a double. [But that did not work for me when I ran it.]
Dang promotion rules. It works for logical and char

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

mohd akmal masud
mohd akmal masud 2018년 2월 20일
hi all,
i have image dicom 16 bit. Like below my image:
>>P=dicomread('PET_I1001_PT135.dcm');
>> whos P
Name Size Bytes Class Attributes
P 256x256 131072 int16
My problem is, 16 bit image can stored pixel value till 32767 only. Now i want change it to 32 bit or 64 bit so that the pixel value can stored more than that, and corresponding how much activity radionuclides i used to diagnosed patient.
can you help to convert that using matlab? or anyway to solve it?

댓글 수: 1

Jan
Jan 2018년 2월 20일
편집: Jan 2018년 2월 20일
@mohd akmal masud: Please do not hijack an old existing thread by appending a new question in the section for answers. Afterwards it would be unclear, to which question an answer belongs and you cannot select an accepted answer. Delete this message here and open a new thread. Thanks.
By the way: P64 = int64(P)

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

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

Jim
2013년 5월 25일

편집:

Jan
2018년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by