Computer Vision-Lec 02
Computer Vision-Lec 02
Lec 02
What is image?
Image is collection of pixels.
What is pixel?
Pixel is smallest unit in an image which contain color value.
● A good image contain approximately 300 PPI(Pixel Per Inch)
OR DPI(Dot Per Inch)
What is video?
Video is collection of images.
What is image?
Image
#cv2.imread(path,flag)
img1=cv2.resize(img1,(3,4))#3=width(column(x), 4=height(row(y))
print(img1)
cv2.imshow("picture",img1)
cv2.waitKey() x(column)=0,y(row)=1
[
[103 132 87]
[ 99 226 116]
[ 66 70 110]
[ 98 49 80]
]
pixel intensity of x=1,y=1 226
Sampling and Quantization
An image may be continuous with respect to the x- and y-coordinates, and also in
amplitude.
To digitize it, we have to sample the function in both coordinates and also in
amplitude.
● Digitizing the coordinate values is called sampling.
○ It determines the spatial resolution of the digitized images.
● Digitizing the amplitude values is called quantization.
○ It determines the number of grey levels in the digitized images.
Quantization Level
x=column y
y=row
y+1 x-1,y+1 x,y+1 x+1,y+1
x=column y
y=row
y+1 x,y+1
x=column y
y=row
y+1 x-1,y+1 x+1,y+1
x,y
y
x-1,y-1 x+1,y-1
y-1
x
x-1 x x+1
Nٖ8(p) Neighborhood
Any pixel can be represented by
x=column y
y=row
y+1 x-1,y+1 x,y+1 x+1,y+1
Union of
x-1,y x,y x+1,y
y
Nٖ4(p) and NٖD(p)
x-1,y-1 x,y-1 x+1,y-1
y-1
x
x-1 x x+1
ADJACENCY
● Let V be the set of intensity values used to define adjacency
4-adjacency
54 10 58 8
81 150 2 34
201 200 3 45
7 70 147 56
V={1,2,3,....10}
m-adjacency
Two pixels p and q with values from V are m-adjacent if
● q is in N4(p)
OR
● q is in ND(p) and the set N4(p) ∩ ND(p) has no pixels whose
values are from V.
Fig : A
Fig : D
Distance Measure
For pixels p, q with coordinates (x,y) , (u,v)
● The pixels with D4 distance ≤ 2 from (x, y) (the center point) form the following
contours of constant distance:
● D4(p, q) = |x-u| + |y-v|
● The pixels with D4 = 1 are the 4-neighbors of (x,y)
1
3
Chess Board Distance
Arithmetic operations between two images f(x,y) and g(x,y) are denoted as
4 0 10 + 2 0 0 = 6 0 10
8 0 5 0 10 10 8 10 15
Usage:
4 0 10 2 0 0 2 0 10
8 0 5 0 10 10 8 0 0
Usage:
● Removal of background from images
● Image enhancement
● Image matching
● Moving/displaced object tracking
Removal of background from images
Multiplication and Division
● compositing of images
Not Operator
negative of the original image.
Neighbourhood Operation
Image Enhancement
● is a process to improve the quality of image.
● To highlight the important detail
● To remove noise
Method of image enhancement
● Spatial domain
● Frequency domain
● Combination method
Spatial Domain
141 252 99
201 15 76
Obtain the digit negative of the following 8-bit per
pixel image
116 50 150
L=28 = 256 139 205 105
the masks can be designed for noise reduction, edge detection, etc.
Smoothing Filters
● Smoothing filters are used for blurring (removal of small details from
an image prior to large object extraction) and for noise reduction
Low pass Filter:
● Low pass filter always has positive coefficients
● Sum of the coefficients is equal to 1
● It blurs edges
Low Pass filtering
Simple average filters:
Median filtering
● if the objective is to achieve noise reduction rather than blurring, use median
filter.
● less
Spatial image Sharpening
Goals: highlight or enhance details in images.
● To highlight fine detail
● Remove blurring from image
● Highlight edges
Procedure: Based on spatial differentiation.
Applications:
● Photo enhancement
● Medical image visualization
● Industrial defect detection
Spatial Differentiation
● Rate of change of function
● Consider 1-D example
1st derivative
● Must be zero in flat segments (area of constant grey levels)
● Must be non zero at the onset of grey level step or ramp
● Must be non zero along ramps
2nd Derivative
● Must be zero in flat segment
● Must be non zero at the onset and end of a gray level step or ramp
● Must be non zero along ramps of constant slope
1st vs 2nd Derivative comparison
● Must be non zero at the onset ● Must be non zero at the onset
of grey level step or ramp and end of a gray level step or
ramp
● Must be non zero along ramps ● Must be non zero along ramps
of constant slope
f(x,y) g(x,y)
Unsharp Mask & High Boost Filtering
Using sequence of linear Spatial filters in order to get sharpening effect.
● Blur
● Subtract from original image
● Add resulting mask to original image
A=K
Horizontal Filter:
Vertical Filter
1st Derivative Filter
● Robert
● Sobel
● Prewitt Filter
Roberts cross-gradient operators.