Professional Documents
Culture Documents
Science
1
Section (3) Digital Image Processing
MATLAB R2013
2
Section (3) Digital Image Processing
MATLAB R2013
3
Section (3) Digital Image Processing
MATLAB R2013
4
Section (3) Digital Image Processing
MATLAB R2013
5
Section (3) Digital Image Processing
MATLAB R2013
6
Section (3) Digital Image Processing
By using MatLab, try to read a color image and then add (100) to each pixel in each layer (channel) and show the
two images, then try to subtract (100 ) from each pixel in each layer and show the two images also.
7
Section (3) Digital Image Processing
MATLAB R2013
8
Section (3) Digital Image Processing
MATLAB R2013
9
Section (3) Digital Image Processing
1. Average method
2. Lightness (Desaturation) Method
3. Weighted method or luminosity method
10
Section (3) Digital Image Processing
Explanation
There is one thing to be sure , that something happens to the original image. It means that our average method
works. But the results were not as expected. We wanted to convert the image into a grayscale , but this
turned out to be a rather black image.
11
Section (3) Digital Image Processing
This method is the most boring. “Averaging” is the most common grayscale conversion routine, and it works
like this:
Gray = (Red + Green + Blue) / 3
It is fast and simple algorithm for rookie programmers. This formula generates a reasonably nice grayscale
equivalent. while this formula is fast and simple, it does a poor job of representing shades of gray relative to the
way humans perceive luminosity (brightness). For that, we need something a bit more complex.
12
Section (3) Digital Image Processing
13
Section (3) Digital Image Processing
Desaturation results in a flatter, softer grayscale image. Desaturation looks like the kind of grayscale photo you
might take with a cheap point-and-shoot camera.
14
Section (3) Digital Image Processing
Explanation
Because humans do not perceive all colors equally, the “average method” of grayscale conversion is
inaccurate. Instead of treating red, green, and blue light equally, a good grayscale conversion will weight
each color based on how the human eye perceives it. As you can see here , that the image has now been
properly converted to grayscale, and the image is more brighter.
15
Section (3) Digital Image Processing
Thresholding is the simplest method of image segmentation (As will be seen later). It can be used to create
binary images from a grayscale image.
The simplest thresholding methods replace each pixel in an image with a black pixel if the image intensity ( i )
is less than some fixed constant T (that is, i<T), or a white pixel if the image intensity is greater than that
constant.
0
1
Which means if the pixel value in the Grayscale image is less than 128 it will be converted into black (0)
otherwise it will be converted into White (1).
16
Section (3) Digital Image Processing
17
Section (3) Digital Image Processing
Assignment # 3
Write a MatLab code that generates the following grayscale (one channel) image.
Hint : (0-black , 255 – white)
18
Computer
Science
19