EEEB 0765 Digital Signal Processing for Embedded Systems
EEEB 0765 Digital Signal Processing for Embedded Systems 8 Video and Image Processing in Embedded Systems (I) Assoc. Prof. Dr. Peerapol Yuvapoositanon Dept. of Electronic Engineering EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-1
Outline • Fundamental of Video and Image Processing – Morphological Operations – Video Play in Simulink • Hands on Simulation with Matlab and Simulink EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-2
Mathematical Morphology • Morphology is the study of the shape and form of objects. – Object extraction – Image filtering operations, such as removal of small objects or noise from an image – Image segmentation operations, such as separating connected objects – Measurement operations, such as texture analysis and shape description EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-3
Kernel 3 x 3 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-4
Strel= Structuring Element • SE = strel('arbitrary', NHOOD) creates a flat structuring element where NHOOD specifies the neighborhood. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-5
Strel Examples (I) • SE = strel('disk', R, N) creates a flat, diskshaped structuring element, where R specifies the radius. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-6
Strel Examples (II) • SE = strel('diamond', R) creates a flat, diamond -shaped structuring element • R specifies the distance from the structuring element origin to the points of the diamond EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-7
Dilation and Erosion Dilation Erosion http: //homepages. inf. ed. ac. uk/rbf/HIPR 2/matmorp h. htm EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-8
Opening and Closing Opening EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon Closing DSPEB-9
Dilating • If at least one pixel in the structuring element coincides with a foreground (i. e. , “ 1”) pixel in the image underneath, then the input pixel is set to the foreground (1) value http: //homepages. inf. ed. ac. uk/rbf/HIPR 2/dilate. htm EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-10
Corner is rounded off EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-11
Grey Scale Dilation EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-12
Erosion • If for every pixel in the structuring element, the corresponding pixel in the image underneath is a foreground pixel, then the input pixel is left as it is. If any of the corresponding pixels in the image are background, however, the input pixel is also set to background value. From http: //homepages. inf. ed. ac. uk/rbf/HIPR 2/erode. htm EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-13
hole in the middle of the image increases in size EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-14
Grey Scale Erosion EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-15
Erosion: Separate coins before counting EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-16
Opening • An erosion followed by a dilation using the same structuring element for both operations. From http: //homepages. inf. ed. ac. uk/rbf/HIPR 2/open. htm EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-17
Opening vs. Erosion • The basic effect of an opening is somewhat like erosion in that it tends to remove some of the foreground (bright) pixels from the edges of regions of foreground pixels. • However it is less destructive than erosion in general. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-18
Opening: Separate out the circles from the lines EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-19
Opening EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-20
Opening: Salt Noise EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-21
Opening: Dark Noise EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-22
Opening: Count the Spokes using Opening EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-23
Run the Matlab commands >> I= imread('testpat 1. png'); >> imshow(I) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-24
Closing • Closing is opening performed in reverse. • Simply as a dilation followed by an erosion From http: //homepages. inf. ed. ac. uk/rbf/HIPR 2/close. htm EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-25
Closing vs. Dilation • Closing is similar in some ways to dilation in that it tends to enlarge the boundaries of foreground (bright) regions in an image (and shrink background color holes in such regions). • But it is less destructive than dilation of the original boundary shape. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-26
Closing: Removing Small Holes EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-27
Closing EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-28
EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-29
Try to erase all those lines! EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-30
Closing: Finding Skeleton EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-31
Closing EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-32
Dark Noise EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-33
Salt Noise EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-34
Mplay and implay >>implay('rhinos. avi'); % Use implay >>mplay('rhinos. avi'); % mplay will be removed in future release EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-35
Read and Play Video File >> video. FReader = vision. Video. File. Reader('viplanedeparture. avi'); >> video. Player = vision. Video. Player; >> while ~is. Done(video. FReader) video. Frame = step(video. FReader); step(video. Player, video. Frame); end >> release(video. Player); >>release(video. FReader); EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-36
EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-37
>> I = imread('circuit. tif'); >> corners = detect. FASTFeatures(I, 'Min. Contrast', 0. 1); >> J = insert. Marker(I, corners, 'circle'); >> imshow(J); EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-38
EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-39
Edge Detection and Image Overlay EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-40
Edge Detection and Image Overlay EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-41
EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-42
Edge Detection and Image Overlay + Pixel Stream HDL Model EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-43
Tracking Cars Using Foreground Detection EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-44
Tracking Cars Using Foreground Detection (result) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-45
- Slides: 45