# How to define or generate a 4 bit or 5 bit image? (how to define image bit rate/resolution)

Discussion in 'MATLAB' started by Ross, Dec 19, 2007.

1. ### RossGuest

Typically, I work with 8 bit images. In an 8 bit image, 0
is the lowest intensity and 255 is the highest intensity.

I'm trying to generate a matrix and use imshow to display
that matrix (image) - except it needs to have the
intensities ranging from 0 - 15 with 0 being the lowest and
15 being the highest.

I'm not sure how to define the bit rate/ resolution of an
image. Any suggestions?

Ross, Dec 19, 2007

2. ### Bruno LuongGuest

help bitshift

Bruno

Bruno Luong, Dec 19, 2007

3. ### RossGuest

Bruno, thanks. I tried using bitshift but it isn't working
for me. I'm probably not doing it right.

I just realised that all the images that I've defined so
far have been in the "double" format. Basically, the range
of the image is [0 1] with 0 being black and 1 being white.
0.5 would be halfway through.

However, I'm not sure how to define a 4 with range [1 15]
or 5 bit image with range [0 31]

While I've worked with 8 bit and 16 bit images in the past,
I'm not sure how to define one so that matlab interprets
the intensity values correctly.

Ross, Dec 19, 2007
4. ### Matthew WhitakerGuest

Ross,
You need to turn your grascale image into andexed image
doc gray2ind %in image processing toolbox
[X, map] = gray2ind(I, 16);
imshow(X, map);

Hope this helps
Matt

Matthew Whitaker, Dec 19, 2007
5. ### Walter RobersonGuest

Use the two parameter version of imshow:

IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display
range for I in [LOW HIGH]. The value LOW (and any value less than LOW)
displays as black, the value HIGH (and any value greater than HIGH) displays
as white. Values in between are displayed as intermediate shades of gray,
using the default number of gray levels. If you use an empty matrix ([]) for
[LOW HIGH], IMSHOW uses [min(I)) max(I))]; that is, the minimum value in
I is displayed as black, and the maximum value is displayed as white.

See also the property 'clim' (I don't recall at the moment which
object it is a property of.)

Walter Roberson, Dec 19, 2007