TP1-IMAGEVISION
TP1-IMAGEVISION
1. DIP
Digital image processing (DIP) has the different techniques for processing of digital images.
DIP has been applying many fields with technological advances, such as Medicine,
Geographical Information Technologies, Space Sciences, Military Applications, Security,
Industrial Applications.
Pixel
Pixels, which are called pel or picture elements, may be defined as the smallest addressable
element in the digital image. Pixels of a color image have Red, Green, and Blue gray values
(Figure 2).
Figure 1.Image.
1
TP IMAGE & VISION © JLASSI HAGER
Neighbors of a pixel
A pixel has three different neighbor types that are 4, 8, and diagonal. As shown in Table 1,
neighbor of a pixel (p) in the x, y point of image (f) is defined in that 4‐neighbors;
N4(p)is shown as 4‐neighbor of P (pixel). Any pixel p in the imagehastwo vertical and
horizontal neighbors, and each of them is a unit distance of p, given by
N4p=fx,y-1,fx-1,y,fx,y+1,fx+1,y
Diagonal neighbors
Although diagonal neighbors are the same of 4‐neighbor, neighbor pixels are the corner of
pixels (p) and each of them is at Euclidean distance of p, given by
NDp=fx-1,y-1,fx-1,y+1,fx+1,y+1,fx+1,y-1
8‐neighbors
Adjacency
If two pixels are neighbors and their gray level values satisfy some specified criterion, then
they are connected. A set of intensity values(V) isused to define adjacency and connectivity.
There are three types of adjacency (Figure 3).
4‐adjacency
P and q pixels are 4‐adjacency if they are N4(p) with values from V.
8‐adjacency
P and q pixels are 8‐adjacency if they are N8(p) with values from V.
m‐adjacency (mixed)
3
TP IMAGE & VISION © JLASSI HAGER
Path
A path from pixel p with coordinate (x,y) to pixel q with coordinate(s,t)with values from V is
defined as 4‐‐ ,8‐ , or m‐paths depending on the type of adjacency specified.
5
TP IMAGE & VISION © JLASSI HAGER
MATLAB is a very simple software for coding. All data variable in MATLAB are thought a
matrix and matrix operations are used for analyzing them. MATLAB has the different
toolboxes according to application areas. In this section, MATLAB Image Processing
Toolbox is presented and the use of its basic functions for digital image is explained.
imread() function is used for reading image. If we run this function with requiring data,
image isconverted to a two‐dimensional matrix (gray image is two‐dimensional, but, color
image is three‐dimensional) with rows and columns including gray value in the each cell.
I=imread(‘path/filename.fileextension');
imread() function only needs an image file. If the result of imread() function is equal to a
variable, a matrix variable(I) is created. Filename, extension, and directory path that contains
image must be written between two single quotes. If script and mage file are in the same
folder, path is not necessary.
The matrix variable of image is showed using imshow() function. If many images show with
sequence on the different figure windows, we use “figure” function for opening new
window.
imwrite() function is used to create an image. This function only requires a new image file
namewithextension.Ifthenewimageissavedtoaspecificdirectory,thepath of directory is
necessary.
7
TP IMAGE & VISION © JLASSI HAGER
Image resize
If an image is displayed big or small size for showing details or general view, its resolution
must be changed. These situations are called zoom‐in and zoom‐out. Digital cameras or
photo sensitive devices use optic lenses for zoom‐in and zoom‐out.But, interpolation
methods are only used for digital images. Most common problem of interpolation methods
is the changing quality of image (Figures 10, 11).
I is image variable, if Resize Rate is bigger than1, it means zoom‐in, otherwise zoom‐out.
Figure11. Image resize.
9
TP IMAGE & VISION © JLASSI HAGER
3. Color
Humans have very good photo sensitive devices that are called eyes Newton discovered
that the light has different color spectrum passing through the glass prism. We think human
eye is a glass prism that is called the lens. The lens focuses light to the retina of eyes. So that,
humans see visible color spectrum of light reflected from the objects. Color spectrum is
shown in the Figure 12. Human senses wavelength of light between 400 and 700 nm.
Eyes see colors as combining of primary that are Red(R), Green(G) ,and Blue(B). So that, all
visible colors are produced from primary colors.Secondary colors, which are produced with
adding of primary colors, are Yellow (Red+Green), Magenta (Red+Blue), and Cyan (Green
+Blue) as shown in Figure 13.
In the MATLAB Image Processing Toolbox, a color image has three‐dimensional uint8 (8‐bit
unsigned integer) data. Each dimension corresponds to a color channel that is Red, Green, or
Blue channel. If we want, we can process each color channel. As shown in Figure14, each
color channel splits from image.
Figure 14. R, G, B channel values in the MATLAB workspace.
Figure15. R, G, B channel.
11
TP IMAGE & VISION © JLASSI HAGER
HSI
YIQ
YIQ, which is defined by the National Television System Committee (NTSC), produces the
luminance and the chrominance. We use Equation7 for producing of YIQ components from
RGB image (Figure 18), and Equation 8 is used for converting from YIQ to RGB.
13
TP IMAGE & VISION © JLASSI HAGER
Figure18. YIQ of the Image.
Gray image
Gray image is produced using Equation 9 by NTSC standards. However, we can calculate
different methods, but MATLAB uses NTSC standards and it has rgb2gray (RGB image)
function (Figure 19).
GI0.299R0.587G0.114B (9)
Other methods;
• The average; GI=0.33R+0.33G+0.33B
• The lightness; GI=(max(R,G,B)+(min(R,G,B))/2
15