1 / 88

Image Processing : Basic Concept

Image Processing : Basic Concept. Imaging Systems Overview. Consists of two primary components: Hardware – Image acquisition system, computer, and display devices Software – Image manipulation( 操作 ), analysis, and processing.

tannar
Download Presentation

Image Processing : Basic Concept

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Image Processing : Basic Concept

  2. Imaging Systems Overview • Consists of two primary components: • Hardware – Image acquisition system, computer, and display devices • Software – Image manipulation(操作), analysis, and processing

  3. Image is accessed (存取) as a 2-D array (陣列) of data, where each data point is referred to as a pixel (像素) Notation: I(r,c) = Brightness (亮度) of image at the pt (r,c) where r = row(列), and c = column(行)

  4. Visible Light Imaging • Reflectance (反射) function determines manner in which objects (物體) reflect light

  5. Sensors : Converts (轉換) light energy into electrical energy a) Single imaging sensor ; b) Linear ( line) sensor ; c) 2-D or array sensor • CCD: 4kx4k CMOS: less power, cheaper, image quality not as good as CCD

  6. Image Representation • Optical (光學) image : Collection of spatially distributed (空間分佈) light energy measured by an image sensor to generate I(r,c) • Matrix: 2-D array like the image model, I(r,c) • Vector: One row or column in a matrix

  7. Image Types • Binary (二元化) images: Simplest type of images, which can take two values, typically black or white, or “0” or “1” • Gray scale (灰階) images: One-color or monochrome images that contains only brightness information and no color information • Color images: 3 band monochrome images, where each band corresponds to a different color, typically red, blue and green or RGB

  8. Color pixel vector: Single pixel’s values for a color image, (R,G,B) • Multispectral(多光譜)Images: Images of many bands containing information outside of the visible spectrum(可見光譜)

  9. Color Transform/Color Model • Mathematical model or algorithm to map(映射) RGB data into another color space (色彩空間) • Decouples (分開) brightness and color information • Hue(色調)/Saturation(飽和度)/Lightness(亮度) (HSL) Color Transform: • Describes colors in terms that we can more readily understand

  10. Hue corresponds to color, saturation corresponds to the amount of white in color, and lightness is the brightness • For example: a deep, bright orange color would have a large intensity (bright), a hue of “orange” , and a high value of saturation (“deep(深度)”) But in terms of RGB components, this color would have the values as R =245, G= 110, and B=20

  11. Equations for mapping RGB to HSL are: where

  12. Digital Image File Formats • Bitmap images (raster images): Images that can be represented by our image model, I (r,c)

  13. Image file header (檔案標頭): A set of parameters (參數) found at the start of the file image and contains information regarding: • Number of rows (列數)(height, 高) • Number of columns (行數)(width, 寬) • Number of bands (頻帶數) • Number of bits per pixel (每個像數之位 元數)(bpp) • File type (檔案形式)

  14. Look-up table (LUT): Used for storing RGB values for 8-bit color images

  15. Common image file formats are: • BIN, RAW • PPM,PBM,PGM • BMP • JPEG • TIFF • GIF • RAS • SGI • PNG • PICT, FPX • EPS • VIP

  16. Matlab 影像處理I/O相關指令簡介 • 在Matlab中,每一個像素(pixel)之顏色係以0到1之數值來表示。1代表最亮,0代表最暗。 • 彩色的組成係由RGB,也就是 red(紅) 、green(綠) 、blue(籃)的色階來構成。 • 影像之處理係基於矩陣的運算,矩陣內的數值,代表了影像的強弱。

  17. Matlab 影像處理I/O相關指令簡介 • 黑白影像用二維的矩陣來表示,彩色的影像則需藉助三維的矩陣來表示RGB 在該一位置的色濃度。

  18. Matlab 影像處理I/O相關指令簡介 • Show 圖指令imshow( ) • 其指令格式為:imshow(影像矩陣 A,色階 N) ,代表影像矩陣 A以N個色階來顯示黑白影像。 • 若N未設定,則對24位元之影像,內定為256色階。 • 影像矩陣A以三維空間A( : , : , 3)來表示彩色影像,A(: , : , 1)表示紅色之色階; A(: , : , 2)表示綠色之色階; A(: , : , 3)表示籃色之色階。

  19. Matlab 影像處理I/O相關指令簡介 • 另外一種設定為設定界限值,以便讓圖形在範圍以下顯示黑色,在範圍以上顯示白色。指令格式為:imshow(影像矩陣 A, [ lim_l lim_h]) • 代表影像矩陣 A 中的值若小於lim_l,則顯示黑色;若大於lim_h,則顯示白色。

  20. Matlab 影像處理I/O相關指令簡介 • 若已經有了現成的影像檔,希望讀入Matlab的workspace中,可用imread(‘檔案名稱’)讀入,再用imshow( )顯示出來即可。 • imwrite( )可用來將影像寫入影像檔中,其指令格式為:imwrite(影像來源, 寫入之影像檔名稱, ‘影像格式’)

  21. Ex2_1.m • clear; close all; • A=imread('1.bmp'); • figure % 開繪圖視窗 • imshow(A); • size(A) • figure • imshow(A(:,:,2)); %僅show綠色部份 • imwrite(A(:,:,2),'ex2_1.tif','tif'); • B=A(100:150,150:200,1); %取紅色之部份影像 • figure • imshow(B); • figure • imshow(B,[100 200]);

  22. Convolution Mask (迴旋遮罩) • Mask Operation (遮罩運算) • 遮罩通常為 3 x 3 (有時使用 5 x 5, 7 x 7)

  23. Convolution: Consist of following process • Overlay (覆蓋) the mask (遮罩) on the image • Multiply the coincident terms (乘上一致的項次) • Sum all the results (將結果加總) • Move to the next pixel, across the entire image Convolution mask for first order hold (一階保持之迴旋遮罩)

  24. Spatial Filters (空間濾波器) • Operate on raw (原始的) image data in the (r,c) space, by considering small neighborhoods (鄰居), 3x3, 5x5, 7x7, and moving sequentially (依序地)across and down the image • Returns a result based on a linear (線性) or nonlinear (非線性) operation

  25. Consists of three types of filters: • Mean filters (均值濾波器) • Median filters (中值濾波器) • Enhancement filters (增強濾波器) • Many spatial filters are linear filters implemented with a convolution mask (以迴旋遮罩來實現); the result is a weighted sum (加權和) of a pixel and its neighbors

  26. Mask coefficients (係數) tend to effect (影響) the image in the following general ways: • Coefficients are positive (正數): blurs (模糊化) the image • Coefficients are alternating positive and negative (正負交替): sharpens (銳化) the image • Coefficients sum to 1 (係數總和為1): brightness retained (保留) • Coefficients sum to 0 (係數總和為1): dark (暗) image

  27. Mean filters (均值濾波器): • Averaging filters (平均濾波器) • Tend to blur (模糊化) the image • Adds a softer look to the image • Example 3x3 convolution mask (迴旋遮罩):

  28. Mean filter Mean filtered image Original image

  29. Median filters (中值濾波器): • Nonlinear filter • Sorts (排序) the pixel values in a small neighborhood and replaces the center (中央的) pixel with the middle value (中間值) in the sorted list (已排序串列) • Output image (輸出影像) needs to be written to a separate image (a buffer (緩衝器)), so that results are not corrupted (破壞) • Neighborhood (鄰居) can be of any size but 3x3, 5x5 and 7x7 are typical (典型)

  30. Median filter Original image with salt and pepper noise (胡椒鹽雜訊) Median filtered image (3x3)

  31. Ex3_2.m (mean filter 與 median filter之練習) • %Image: 原影像 • %Image_noisy: 受污染的影像% • %Image_low: 執行低通濾波器後的影像% • %Image_med: 執行中值濾波器後的影像% • Image=imread('ex2_1.tif'); %讀取影像 • %將胡椒鹽式的雜訊加入原影像中,其中0.06 是雜訊密度% • Image_noisy= imnoise (Image ,'salt & pepper',0.06); • Image2_noisy=double(Image_noisy)/255; %變為 double格式 • h=[1/9 1/9 1/9;1/9 1/9 1/9 ; 1/9 1/9 1/9]; %濾波器的子遮罩 • Image_low=filter2(h, Image2_noisy); %執行低通濾波 • Image_med=medfilt2(Image_noisy,[3 3]); %中值濾波採3×3矩陣 • imshow(Image) • figure,imshow(Image_noisy) • figure,imshow(Image_low) • figure,imshow(Image_med)

  32. Enhancement filters (增強濾波器): • Implemented with convolution masks having alternating positive and negative (正負交替) coefficients • Enhance the image by sharpening (銳化) • Two types considered here: • Laplacian-type (拉普拉斯型) filters • Difference filters (差分型)

  33. 1. Laplacian-type (拉普拉斯型) filters : • Are rotationally invariant (與旋轉無關), that is they enhance the details (增強細節) in all directions equally (所有方向皆相等) • Example convolution masks of Laplacian-type filters are: Filter 1 Filter 2 Filter 3

  34. Laplacian filter Original image Laplacian filtered image Contrast enhanced (對比增強) Version of Laplacian filtered image

  35. 2. Difference (差分) filters: • Also called as emboss (浮雕) filters • Enhances the details in the direction specific (特定方向) to the mask selected • Four primary difference filter convolution masks, corresponding to the edges (邊) in the vertical (垂直), horizontal (水平), and two diagonal directions (對角方向) are: Vertical Horizontal Diagonal 1 Diagonal 2

  36. Difference filter Original image Difference filtered image Difference filtered image added to the original image, with contrast enhanced (對比增強)

  37. Ex3_3.m (增強濾波器之練習) • close all; clear; • A=imread('cat.bmp'); • [m,n]=size(A); %原影像之size為mxn • imshow(A); • CM_lapa=[0 -1 0; -1 5 -1; 0 -1 0]; %Laplacian迴旋遮罩 • CM_diff=[1 0 0; 0 1 0; 0 0 -1]; % difference 迴旋遮罩 • B=filter2(CM_lapa,A); %執行Laplacian 遮罩運算 • C=filter2(CM_diff,A); %執行difference 遮罩運算 • figure; imshow(B/256); • figure; imshow(C/256);

  38. Binary Image Analysis (二元影像分析) • Binary images are useful in many computer vision applications which require simple object shape; such as positioning a robot to grasp (抓取) an object, to check a manufactured object for defects (瑕疵), FAX, OCR(光學字元辨識)

  39. Binary Image Analysis (二元影像分析) • Most cameras provide us color or gray level images, thus we need to convert those images into binary images • Next, we extract (擷取) simple binary features and use them to classify (分辨) binary objects

  40. Thresholding via Histogram (經由直方圖做臨界化) • Thresholding is required to create a binary image (二元影像) from a gray level image (灰階影像) • This is done by specifying a threshold value (指定一臨界值) which will set all values above the specified gray level to ‘1’ and everything below the specified value to ‘0’ • Typically 255 is used for ‘1’ and 0 is used for the ‘0’ value

  41. In many applications the threshold value is determined experimentally (由實驗求得) and is highly dependent on lighting conditions and object to background contrast (與光線條件,目標物與背景之對比度有密切關係) • It is much easier to find a good threshold value with proper lighting, and good background to object contrast

  42. Figure 3.3-1: Effects of Lighting and Object to Background Contrast on Thresholding b) Result of thresholding (臨界化) image (a) a) An image of a bowl with high object to background contrast (目標物與背景之 對比度高) and good lighting (照明良好)

  43. Figure 3.3-1: Effects of Lighting and Object to Background Contrast on Thresholding (contd) c) An image of a bowl with poor object to background contrast (目標物與背景之 對比度低)and poor lighting(照明不佳) d) Result of thresholding image (c)

  44. The histogram (直方圖) is a plot of gray level versus the number of pixels (灰階對像素個數之作圖) in the image at each gray level • Histogram of an image is examined (檢視) to select the proper (適當的) threshold value • The peaks (尖峰) and valleys (深谷) in the histogram are examined and a threshold is experimentally selected (經由實驗選取) that will best separate (最佳的分割) the object from the background (背景)

  45. Figure 3.3-2: Histograms (直方圖) Threshold  b) The histogram of image (a), showing the threshold that separates object and background (一能將目標物與背景 分開之臨界點) a) An image of a bowl with high object to background contrast and good lighting Image after threshold (經臨界化後之影像)

  46. Figure 3.3-2: Histograms (contd) Threshold  d) The histogram of image (c), showing what appears to be a good threshold, but it does not successfully separate object and background c) An image of a bowl with poor object to background contrast and poor lighting Image after threshold

More Related