Hello!
I want to convert uint16 data to uint8 data. I try with uint8 function
but it returns only 255. Ok i understand, what is more than 255 in
original image (uint16) rounds to 255.
Is there any function that does also rescaling data from range [0
65535] to [0 255].
Thank you!!!
Marko
convert uint16 image (data) to uint8 image (data)
Started by ●December 6, 2007
Reply by ●December 7, 20072007-12-07
Hi,
try this :
img16bits=uint16([0 1235 ; 34560 65535]);
img8bits=uint8(255*double(img16bits)/65535);
figure
subplot(2,1,1)
imagesc(img16bits);
axis image
title('16 bits')
subplot(2,1,2)
imagesc(img8bits);
axis image
Je
try this :
img16bits=uint16([0 1235 ; 34560 65535]);
img8bits=uint8(255*double(img16bits)/65535);
figure
subplot(2,1,1)
imagesc(img16bits);
axis image
title('16 bits')
subplot(2,1,2)
imagesc(img8bits);
axis image
Je
Reply by ●December 7, 20072007-12-07
Hi
i think this will work
first convert all the 0 to 65535 into 0 to 1 range by dividing with 65535.
Then multiply with 255 to get 0 to 255 range.
Durga
On Dec 6, 2007 5:40 AM, icemare2000 wrote:
> Hello!
>
> I want to convert uint16 data to uint8 data. I try with uint8 function
> but it returns only 255. Ok i understand, what is more than 255 in
> original image (uint16) rounds to 255.
>
> Is there any function that does also rescaling data from range [0
> 65535] to [0 255].
>
> Thank you!!!
>
> Marko
>
>
>
i think this will work
first convert all the 0 to 65535 into 0 to 1 range by dividing with 65535.
Then multiply with 255 to get 0 to 255 range.
Durga
On Dec 6, 2007 5:40 AM, icemare2000 wrote:
> Hello!
>
> I want to convert uint16 data to uint8 data. I try with uint8 function
> but it returns only 255. Ok i understand, what is more than 255 in
> original image (uint16) rounds to 255.
>
> Is there any function that does also rescaling data from range [0
> 65535] to [0 255].
>
> Thank you!!!
>
> Marko
>
>
>
Reply by ●December 11, 20072007-12-11