0% found this document useful (0 votes)
6 views15 pages

TP1-IMAGEVISION

The document discusses digital image processing (DIP) techniques and their applications across various fields, including medicine and security. It explains pixel relationships, adjacency types, and distance measures, as well as basic image processing functions in MATLAB, such as reading, writing, and resizing images. Additionally, it covers color representation in images, including RGB, HSI, and YIQ color models, along with methods for converting images to grayscale.

Uploaded by

louhichiislem382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views15 pages

TP1-IMAGEVISION

The document discusses digital image processing (DIP) techniques and their applications across various fields, including medicine and security. It explains pixel relationships, adjacency types, and distance measures, as well as basic image processing functions in MATLAB, such as reading, writing, and resizing images. Additionally, it covers color representation in images, including RGB, HSI, and YIQ color models, along with methods for converting images to grayscale.

Uploaded by

louhichiislem382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

TP1

Image & Vision with MATLAB

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

Figure 2.Pixels of a color image.

 Pixels relation ships

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;

f(x‐1,y‐1) f(x‐1, y) f(x‐1,y+1)

f(x, y‐1) p f(x, y+1)

f(x+1,y‐1) f(x+1, y) f(x+1,y+1)

Table 1. Neighbor of a pixel.

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

N4p=fx,y-1,fx-1,y,fx,y+1,fx+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

NDp=fx-1,y-1,fx-1,y+1,fx+1,y+1,fx+1,y-1
8‐neighbors

8‐neighbors is a combination of N4(p) and ND(p) and shown as N8(p).

N8(p) = N4(p) + ND(p)

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).

Figure 3. Pixel adjacency.

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)

P and q pixels are m‐adjacency if;


• q is in N4(p) or,
• q is in ND (p) and,
• N4(p) ∩ N4(q) = ⦰ with values from V.

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.

According to V={2,3,5},If we want to find p and q pixels 44‐,8‐and m‐path,(Figure4)

Figure4.Finding 4‐,8‐,m‐path between p and q pixels.

Distance measures of pixels

• Dm Distance ; it is defined as the shortest m‐path.


According to V={2,3,5}, if we want to find Dm distance from p pixel to q pixel (Figures 5, 6,7);

Figure5.Distance between p and q pixels.

Figure6.Example about the shortest m‐path.

Figure7. Solving example in the Figure 7.

Dm is 5 because orange path is shorter than blue path.

5
TP IMAGE & VISION © JLASSI HAGER

Figure8. Distance measuring type


2. Basic image processing with MATLAB

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.

Read, write, and show image

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).

Figure10. Zoom‐in and zoom‐out.

I_resize = imresize(I, Resize Rate, Interpolation Method)

I is image variable, if Resize Rate is bigger than1, it means zoom‐in, otherwise zoom‐out.
Figure11. Image resize.

Image Sampling and Quantization

1. Loaded and displayed an image.


2. Downsampled the image to reduce its resolution.
3. Quantized the image to reduce the number of colors.
4. Combined both downsampling and quantization.

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.

Figure12. Color spectrum

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.

Figure13. Primary and secondary colors.

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

As shown in Figure 16 each color represents three components as H (Hue), S (Saturation), I


(Intensity).The Hue, which can be defined rate of pure color is an angle form between 0°and
360°. Red, Green, Blue are0°, 120°,and 360°, and Yellow, Cyan, and Magenta are 60°,180°,
300°. The Saturation, which shows how the color to be pure, takes value between [0, 1]. The
intensity is the dimensions of lightness or darkness. The range of intensity is between
0(black) and 1 (white).

Figure 16. HSI components.


Figure 17. HIS of the image.

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).
GI0.299R0.587G0.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

• The luminosity; GI=0.21R+0.72G+0.07B


Figure19. Gray image.

15

You might also like