Tags: array, double, matlab, obtain, programming, uint8, uint8-gt, values

double -> uint8, uint8-> double

On Programmer » Matlab

1,879 words with 4 Comments; publish: Wed, 07 May 2008 12:24:00 GMT; (20046.88, « »)

Hy,

when I put a double array into uint8, and then uint8 into double, I

don't obtain the same values, that seems normal.

But what's the solution if I need to obtain the same values '

If u have any idea..

Thanx

All Comments

Leave a comment...

  • 4 Comments
    • amelie:

      <SNIP slices an apple, eats half of it - and wonders...

      > But what's the solution if I need to obtain the same values...

      in a nutshell - there isn't a solution

      us

      #1; Wed, 07 May 2008 12:25:00 GMT
    • amelie wrote:

      >

      > Hy,

      > when I put a double array into uint8, and then uint8 into double, I

      > don't obtain the same values, that seems normal.

      > But what's the solution if I need to obtain the same values '

      > If u have any idea..

      > Thanx

      Going from double to uint8 throws away precision.

      That precision is lost so that going from uint8 back to double cannot

      recover the original double.

      How can you expect otherwise?

      #2; Wed, 07 May 2008 12:26:00 GMT
    • us wrote:

      >

      > amelie:

      > <SNIP slices an apple, eats half of it - and wonders...

      >

      > in a nutshell - there isn't a solution

      > us

      Just wait a few days, then very carefully put the

      apple back together.

      #3; Wed, 07 May 2008 12:27:00 GMT
    • Well, I found a solution ;) !!

      In fact all the values of my 'double array' are integers between -239

      and 300.

      So I m going to cut my array in three arrays.

      -1) values between -255 & 0

      -2) 0 & 255

      -3) 255 & 300

      Then I'll shift all the values of each array between 0 & 255.

      And put them into uint8......

      So, there is a solution ;)

      Double Trouble wrote:

      >

      > us wrote:

      > values...

      > Just wait a few days, then very carefully put the

      > apple back together.

      #4; Wed, 07 May 2008 12:28:00 GMT