2. 1. Binary: Each pixel is just black or white. Since there are only two possible
values for each pixel (0,1), we only need one bit per pixel.
2. Grayscale: Each pixel is a shade of gray, normally from 0 (black) to 255
(white). This range means that each pixel can be represented by eight bits,
or exactly one byte. Other greyscale ranges are used, but generally they are
a power of 2.
3. True Color, or RGB: Each pixel has a particular color; that color is described
by the amount of red, green and blue in it. If each of these components has
a range 0–255, this gives a total of 2563 different possible colors. Such an
image is a “stack” of three matrices; representing the red, green and blue
values for each pixel. This means that for every pixel there correspond 3
values.
2
Types of digital image
3. 1. Binary Image
• Binary: two possible values for each pixel, we only need one bit per
pixel.
• Each pixel is just black or white.
3
4. 2. Grayscale Image
⚫ Grayscale: Each pixel is a shade of grey, normally from .
⚫ means that each pixel can be represented by eight bits, or exactly one
byte.
4
5. 3. Color Image
⚫ True color or RGB: here each pixel has a particular color, that color
being described by the amount of red, green and blue in it.
⚫ Such an image may be considered as consisting of a stack of three
matrices; representing the red, green and blue values for each pixel.
⚫ This means that for every pixel there correspond three values.
5
6. 4. Indexed Image
⚫ Indexed: Most color images only have a small subset of the more than
sixteen million possible colors.
⚫ For convenience of storage and le handling, the image has an
associated color map.
6
8. Example 4
Given the image ’’Lion.jpg’’, write a Matlab program to generate all
different image types and display all of them.
8
9. Example 5
Write a Matlab program that read an RGB image then separate it’s
three color channels.
9
10. Example 5 Cont.
Write a Matlab program that read an RGB image then separate it’s
three color channels.
10
11. Example 5 Cont.
Write a Matlab program that read an RGB image then separate it’s
three color channels.
11
12. Example 6
Convert intensity image to index image
gray2ind - intensity image to index image
Indexed image
12
A=Imread(‘ cameraman.tif’);
[indimg,map]=Gray2ind(A);
Grayscale image
13. Example 6 Cont.
Convert index image to intensity image
ind2gray - indexed image to intensity image
Code
Load trees
Imshow(X,map)
Grayimg=Ind2gray(X,map);
Imshow(Grayimg)
Indexed image
13
Grayscale image
14. Impixel(i,j) function
⚫ A useful function for obtaining RGB values is impixel
returns the red, green, and blue values of the
pixel at column 200, row 100.
⚫ This command also applies to grayscale images:
return three values, but since g is a single
two-dimensional matrix, all three values
will be the same.
14
16. Iminfo() function
we can see :
the size of the image in pixels,
the size of the file (in bytes),
the number of bits per pixel (this is given by BitDepth),
and the color type (in this case indexed).
16