Tom Cuthill
Tom Cuthill

Reputation: 1

using bitget function to turn double into 8 bits

I am trying to convert a rgb image that is 128x128 pixels x3 for rgb into binary.

I converted the 128x128x3 matrix into a 1x49152 matrix and now want to turn each value into 8 bits/1 byte.

I have been trying to use the bitget function, but don't know how to use it properly.

Upvotes: 0

Views: 731

Answers (1)

mtrw
mtrw

Reputation: 35088

It's unclear to me whether you want to convert your double-valued RGB image to (1) an integer-valued RGB image, or (2) a monochrome image. If the former, the easiest thing to do is

y = uint8(x*intmax('uint8')); %# convert to 24-bit color

This assumes that the double matrix is scaled between 0 and 1. If not, you may need to rescale by dividing x by its maximum value first.

There may be easier ways to do this in the Image Processing Toolbox.

Upvotes: 1

Related Questions