How do I convert a large array of 8 bit binary values in MATLAB? -
This is a follow-up question.
I have a large array of 8 bit binary values that I want to convert back to UIT 8.
I have used Amro's visible solution to the last question. Now I want to reverse. I wanted to have a lookup table but unfortunately I was unable to.
What I have achieved is the following:
temp = ones ([(total pixel), 1], 'UIT 8'; For Iter2 = 1: Total pixels, floating (iter2,1) = sum (data (iter2.1: 8). * 2. ^ (7: -1: 0)); End
But it is very slow for the loop because it takes 2 seconds to change the [76800 x 1] array. Is there a better / faster way to do this?
Try it out:
temp = uint8 (data * (2 ^ (7: -1: 0)) ');
Note that this answer is basically the same as your asking. You asked about changing a line of 12-bit values from here, but I told you about an additional discussion how you can increase it so that one can change multiple values once by using . The difference between that answer and this is only to change the number and variable type of bits.
Comments
Post a Comment