Help with uint8()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with uint8()

Rik-4
Could someone with Matlab try the following code snippet?

uint8 ([-Inf, -1, 300, Inf, NaN])

The documentation says that values outside the range are mapped to the
nearest endpoint.  But does NaN map to 0 or 255?

In Octave the result is

ans =

    0    0  255  255    0

Thanks,
Rik



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Help with uint8()

PhilipNienhuis
Rik-4 wrote

> Could someone with Matlab try the following code snippet?
>
> uint8 ([-Inf, -1, 300, Inf, NaN])
>
> The documentation says that values outside the range are mapped to the
> nearest endpoint.  But does NaN map to 0 or 255?
>
> In Octave the result is
>
> ans =
>
>     0    0  255  255    0

>> uint8 ([-Inf, -1, 300, Inf, NaN])

ans =

  1×5 uint8 row vector

     0     0   255   255     0

Matlab r2018a prerelease



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-Maintainers-f1638794.html


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------