




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、Image Acquisition and Processing by Matlab第 PAGE 55頁CONTENTSBasic Image Acquisition Procedure圖像采集工具箱重要圖解Image Types and Converting 圖像類型及其轉換Displaying and Exploring Images 圖像顯示Spatial Transformations 圖像的幾何運算Image Registration 圖像的對齊Designing and Implementing 2-D Linear Filters for Image Data 二維濾波器Tran
2、sforms 圖像的變換Morphological Operations 形態學運算Analyzing and Enhancing Images 圖像分析和增強ROI-Based Processing 圖像分區域處理Image Deblurring 圖像復原Color 色彩空間Neighborhood and Block Operations 鄰域運算Function ReferenceBasic Image Acquisition ProcedureStep 1硬件安裝Step 2獲取信息 imaqhwinfo InstalledAdaptors: coreco winvideo MATLA
3、BVersion: 7.9 (R2009b) ToolboxName: Image Acquisition Toolbox ToolboxVersion: 3.4 (R2009b) imaqhwinfo(winvideo) AdaptorDllName: C:.toolboximaqimaqadaptorswin32mwwinvideoimaq.dll AdaptorDllVersion: 3.4 (R2009b) AdaptorName: winvideo DeviceIDs: 1DeviceInfo: 1x1 struct imaqhwinfo(winvideo,1) DefaultFor
4、mat: RGB24_320 x240 DeviceFileSupported: 0 DeviceName: USB PC Camera DeviceID: 1 ObjectConstructor: videoinput(winvideo, 1)SupportedFormats: 1x6 cell dev_info.SupportedFormatsRGB24_160 x120 RGB24_176x144 RGB24_320 x240RGB24_352x288 RGB24_640 x480 RGB24_800 x600 dev_info.SupportedFormats(6)RGB24_800
5、x600Step 3創建video input對象 vid = videoinput(winvideo,1,RGB24_800 x600)Summary of Video Input Object Using USB PC Camera . Acquisition Source(s): input1 is available. Acquisition Parameters: Trigger Parameters: 1 immediate trigger(s) on START. Status: .Step 4(optional)預覽視頻流 preview(vid) closepreview(v
6、id)Step 5(optional)配置對象屬性 get(vid) General Settings: DeviceID = , DiskLogger = , DiskLoggerFrameCount = 0 EventLog = 1x0 struct, FrameGrabInterval = 1, FramesAcquired = 0 FramesAvailable = 0, FramesPerTrigger = 10, Logging = off LoggingMode = memory, Name = RGB24_800 x600-winvideo-1 NumberOfBands =
7、3, Previewing = off, ROIPosition = 0 0 800 600 Running = off, Tag = , Timeout = 10, Type = videoinput, UserData = VideoFormat = RGB24_800 x600, VideoResolution = 800 600 Color Space Settings: BayerSensorAlignment = grbg, ReturnedColorSpace = rgb Callback Function Settings: ErrorFcn = imaqcallback, F
8、ramesAcquiredFcn = FramesAcquiredFcnCount = 0, StartFcn = , StopFcn = , TimerFcn = TimerPeriod = 1, TriggerFcn = Trigger Settings: InitialTriggerTime = , TriggerCondition = none, TriggerFrameDelay = 0 TriggerRepeat = 0, TriggersExecuted = 0, TriggerSource = none TriggerType = immediate Acquisition S
9、ources: SelectedSourceName = input1, Source = 1x1 videosource get(getselectedsource(vid) General Settings: Parent = 1x1 videoinput, Selected = on, SourceName = input1, Tag = Type = videosource Device Specific Properties: BacklightCompensation = on, Brightness = 20, ColorEnable = on, Contrast = 20 Ex
10、posure = 1, FrameRate = 30.0000, Gamma = 4, Hue = 18Saturation = 50, Sharpness = 3 set(vid,TriggerRepeat,Inf); vid.FrameGrabInterval = 5; vid_src = getselectedsource(vid); set(vid_src,Tag,motion detection setup);Step 6獲取圖像數據 start(vid) data=getdata(vid,6); stop(vid)Step 7清理 delete(vid) clear close(g
11、cf)圖像采集工具箱重要圖解The Image Acquisition Toolbox Software ComponentsRelationship of Video Input Objects and Video Source ObjectsTransitions from Running to Stopped StatesLogging State TransitionsOverview of Data LoggingImmediate TriggerManual TriggerHardware TriggerSpecifying the Amount of Data to LogImp
12、act of FrameGrabInterval on Data LoggingFrames Available After Initial Trigger ExecutionContents of Memory Buffer Before and After Removing FramesSpecifying a Delay Before Data Logging BeginsExecuting Multiple TriggersUsing wait to Block the MATLAB Command LineDelete a triggers worth of image data (
13、The frames acquired before and after the call to flushdata)Logging Data to a Disk FileOverview of Image Acquisitiongetdata Blocks Until Frames Become AvailableFrames Returned by peekdataFormat of an Individual FrameInitialTriggerTime Records First Trigger ExecutionImage Types and Converting 圖像類型及其轉換
14、ditherDithering(抖動)是Gif壓縮中一項十分有用的技術。由于GIF 和PNG只有256種顏色,因此,在表現一些含有豐富色彩信息的照片圖像或含有平緩過度色的圖像時,就會出現梯田狀的條形色塊,這時,我們就需要用到Dithering(抖動)功能,Dithering可以模仿一些在調色板無法找到的顏色,從而使得整個圖像顏色與顏色之間的過渡更為自然,不過,Dithering同樣會使圖像Size變大,因此,我們更多的將這項技術應用于區域壓縮。demosaicConvert Bayer pattern encoded image (與相機RAW格式相關) to truecolor (RGB)
15、image.類型轉換gray2ind,grayslice,im2bw,ind2gray,ind2rgb,mat2gray,rgb2gray,rgb2indImage class 轉換im2uint8, im2uint16, im2int16, im2single, or im2doubleimapprox索引圖像轉換可能使用,Approximate indexed image using one with fewer colorsImage Arithmetic Saturation RulesValues that exceed the range of the integer type a
16、re saturated to that range如300255,-450Fractional values are roundedDICOMDICOM(Digitalimaging and Communications in Medicine)即數字影像和通信標準,規范醫學影像及其相關信息的交換。由美國發射學會和美國國家電器制造商協會NEMA(National Electronical Manufacturers Association)制定。從文件格式上看,用于保存醫學數據的DICOM包容的信息量大(除圖像信息外,還有很多附加信息,比如患者病例檔案等),格式復雜。DICOM的壓縮算法種類
17、很多,也可以保存動畫圖像DICOM的圖像基本都是與醫學相關的(MRI,CT等),醫學圖像的特點是分辨率低,特征不清晰等等。對這類圖像做分割和特征提取難度較大。Mayo Analyze 7.5A file format, developed by the Mayo Clinic, for storing MRI(Magnetic Resonance Imaging核磁共振成像) data,包含兩個文件.hdr和.img。Interfile為了使核醫學圖像和信息能在不同系統上共享,傳遞以前將各系統的文件轉換成統一的Interfile文件格式。轉換后的圖像和文件,就可以在不同廠商的計算機上進行圖像傳
18、遞。High Dynamic Range ImagesDynamic range refers to the range of brightness levels, using 32-bit floating-point values to store each color channel. hdrread,makehdr,tonemap(HDR-RGB),hdrwriteDisplaying and Exploring Images 圖像顯示Displaying Images Using the imshow FunctionImage Displayed in a Figure Windo
19、w by imshow imshow(moon.tif); I = getimage; % assigns the image data from the figure window currently activeSpecifying the Initial Image Magnification imshow(I, InitialMagnification, 150)Image Displayed With and Without a Border imshow(I,Border,tight) % tight|looseDisplaying Each Image in a Separate
20、 Figure figureDisplaying Multiple Images in the Same Figure subplot(m,n,p) subplot(1,2,1), imshow(I1)Using imtool to Explore ImagesOpening the Image Tool imtool(moon.tif);Specifying the Initial Image MagnificationSpecifying the ColormapImporting Image Data from the WorkspaceExporting Image Data to t
21、he WorkspaceSaving the Image Data Displayed in the Image ToolClosing the Image Tool imtool close allExploring Very Large ImagesCreate reduced resolution data set (R-Set) from image file rsetfile = rsetwrite(File_Name) rsetfile = rsetwrite(File_Name, output_filename)File_Name is a TIFF or NITF image
22、fileViewing Image Sequences 查看圖像序列Viewing Image Sequences in the Movie Player load mristack % implay(mristack)Viewing Image Sequences as a Montage I=reshape(mristack,256 256 1 21); % repmat may be used montage(I)Converting a Multiframe Image to a Movie I=reshape(mristack,256 256 1 21); mov = immovie
23、(I); implay(mov)Displaying Different Image Types (imshow和imtool可替換)Displaying Grayscale Images That Have Unconventional Ranges imshow(I,DisplayRange,low high) imtool(I,DisplayRange,);Changing the Display Colors of a Binary Image imshow(BW) imshow(BW,1 0 0; 0 0 1)Adding a Colorbar to a Displayed Imag
24、e colorbarSetting Toolbox PreferencesViewing and Changing Preferences Using the Preferences Dialog Boxselect Preferences Image Processing in the File menuRetrieving the Values of Toolbox Preferences Programmatically iptgetpref(ImtoolInitialMagnification)Setting the Values of Toolbox Preferences Prog
25、rammatically iptsetpref(ImshowBorder, tight);Spatial Transformations 圖像的幾何運算基本運算Resizing I1 = imresize(I,1.25); X1 = imresize(X,100 150,bilinear)Rotating I1 = imrotate(I,35,bilinear);Cropping I1 = imcrop(I); I1 = imcrop(I,60 40 100 90);Performing General 2-D Spatial TransformationsOverview of Genera
26、l 2-D Spatial Transformation ProcessExample: Performing a TranslationStep 1: Import the Image to Be Transformed I = checkerboard; % Step 2: Define the Spatial Transformation xform = 1 0 0; 0 1 0; 40 40 1 ;Step 3: Create the TFORM Structure tt = maketform(affine,xform);Step 4: Perform the Transformat
27、ion I1 x1 y1= imtransform(I,tt);Step 5: View the Output ImageAffine Transform仿射變換是一種二維坐標到二維坐標之間的線性變換,保持二維圖形的“平直性”(straightness,即變換后直線還是直線不會打彎,圓弧還是圓?。┖汀捌叫行浴保╬arallelness,其實是指保二維圖形間的相對位置關系不變,平行線還是平行線,相交直線的交角不變。)。仿射變換可以通過一系列的原子變換的復合來實現,包括:平移(Translation)、縮放(Scale)、翻轉(Flip)、旋轉(Rotation)和錯切(Shear)。Creati
28、ng TFORM StructuresTransformation Type: affine,projective,box,custom,compositePerforming N-Dimensional Spatial Transformations maketform makeresampler imtransform其它:fliptform,tformfwd,tforminv,findbounds,tformarrayImage Registration 圖像的對齊A graphic illustration of the image registration processExampl
29、e: Performing a registrationStep 1: Read the ImagesStep 2: Choose Control Points in the Images by cpselect I0=imread(westconcordorthophoto.png); % base I1=imread(westconcordaerial.png); % input cpselect(I1, I0)Step 3: Save the Control Point Pairs to the MATLAB Workspace點擊File-Export Points to Worksp
30、ace,得到base_points input_pointsStep 4: Fine-Tune the Control Point Pair Placement (Optional) INPUT_POINTS = cpcorr(input_points,base_points,I1,I0)Step 5: Specify the Type of Transformation and Infer Its Parameters mytform = cp2tform(INPUT_POINTS, base_points, projective)Step 6: Transform the Unregist
31、ered Image Ir = imtransform(I1, mytform);查看對齊效果 imshow(Ir) hold on h = imshow(I0, gray(256); set(h, AlphaData, 0.6)cp2tform Transformation Typesnonreflective similarityaffineprojectivepolynomialpiecewise linearlwm (local weighted mean)Designing and Implementing 2-D Linear Filters for Image Data 二維濾波
32、器Designing and Implementing Linear Filters in the Spatial DomainConvolution 卷積Step 1: Rotate the convolution kernel 180 degrees about its center element.Step 2: Slide the center element of the convolution kernel so that it lies on top of the (2,4) element of A.Step 3: Multiply each weight in the rot
33、ated convolution kernel by the pixel of A underneath.Step 4: Sum the individual productsCorrelation 相關不旋轉kernel,其余與卷積相同Performing Linear Filtering of Images Using imfilter I1 = imfilter (I0, h)default method:相關Boundary Padding:default(the value x=0,即zero padding), x,replicate,symmetric,circularRelat
34、ionship to Other Filtering Functionsfilter2二維相關,cov2二維卷積,covn-n維卷積,這些函數與imfilter在于它們的輸出數據類型一定是double,并使用zero paddingFiltering an Image with Predefined Filter Types by fspecial average averaging filter disk circular averaging filter gaussian Gaussian lowpass filter laplacian filter approximating the
35、2-D Laplacian operator log Laplacian of Gaussian filter motion motion filter prewitt Prewitt horizontal edge-emphasizing filter sobel Sobel horizontal edge-emphasizing filter unsharp unsharp contrast enhancement filterDesigning Linear Filters in the Frequency Domain FIR FiltersFIR (finite impulse re
36、sponse) filters have a finite extent to a single point, or impulse. All the Image Processing Toolbox filter design functions return FIR filters.Frequency Transformation Methodftrans2 transforms a one-dimensional FIR filter into a two-dimensional FIR filterdefault method:produces filters with nearly
37、circular symmetryFrequency Sampling Methodfsamp2 returns a filter h with a frequency response that passes through the points in the input matrix Hd Hd = zeros(11,11); Hd(4:8,4:8) = 1; % 構造階躍平臺 h = fsamp2(Hd); % Hd-h轉換 freqz2(h) % 顯示濾波器頻譜缺點:Ripples波紋Windowing Methodfwind1 designs a 2D filter by using
38、 a 2D window that it creates from one or two 1D windows that you specify. fwind2 designs a 2D filter by using a specified 2D window directly.Creating the Desired Frequency Response Matrixfreqspace returns correct, evenly spaced, frequency values for any size response. f1,f2 = freqspace(25,meshgrid);
39、 Hd = zeros(25,25); d = sqrt(f1.2 + f2.2) Hd(d) = 1; mesh(f1,f2,Hd)For this frequency response, the filters produced by fsamp2, fwind1, and fwind2 are real. This result is desirable for most image processing applications.Transforms 圖像的變換Discrete Fourier Transform卷積的計算 ifft2(fft2(A).*fft2(B)卷積定理:兩個二維
40、連續函數在空間域中的卷積可求其相應的二個傅立葉變換乘積的反變換而得,即 f(x,y) 卷積 h(x,y) F(u,v) H(u,v) 卷積滿足交換律,是線性運算,還滿足分配律、結合律相關的計算real(ifft2(fft2(bw).*fft2(rot90(a,2),256,256)與卷積的區別,Kernel圖像要先旋轉180度Discrete Cosine TransformDCT相當于長度是它兩倍的離散傅里葉變換,這個離散傅里葉變換是對一個實偶函數進行的(因為一個實偶函數的傅里葉變換仍然是一個實偶函數)DCT經常被信號處理和圖像處理使用,用于對信號和圖像(JPEG和MPEG等)進行有損數據壓
41、縮。當信號具有接近Markov processes的統計特性時,DCT的去相關性接近于具有最優的去相關性的Karhunen-Love(K-L)變換的性能。 The DCT Transform Matrix 本方法適用于small square imputs,如8x8,16x16dctmtx makes discrete cosine transform matrixT*I*T 等價于 dct2(I) % T=dctmtx(size(I,1),I是正方形圖像Radon Transform R,xp = radon(I,theta); IR = iradon(R,theta);點光源投影變換 fa
42、nbeam和ifanbeamMorphological Operations 形態學運算Dilation and Erosion 膨脹和腐蝕CommandOperation RulePadding Rule膨脹imdilateThe value of the output pixel is the maximum value of all the pixels in the input pixels neighborhood. Pixels beyond the image border are assigned the minimum value afforded by the data t
43、ype. Generally, these pixels are set to 0. 腐蝕imerodeThe value of the output pixel is the minimum value of all the pixels in the input pixels neighborhood. Pixels beyond the image border are assigned the maximum value afforded by the data type. BW: set to 1. uint8 grayscale images: set to 255.Structu
44、ring Elements: a matrix consisting of only 0s and 1s that can have any arbitrary shape and size. The pixels with values of 1 define the neighborhood.SE = strel(arbitrary, NHOOD)SE = strel(arbitrary, NHOOD, HEIGHT)SE = strel(ball, R, H, N)SE = strel(diamond, R)SE = strel(disk, R, N)SE = strel(line, L
45、EN, DEG)SE = strel(octagon, R)SE = strel(pair, OFFSET)SE = strel(periodicline, P, V)SE = strel(rectangle, MN)SE = strel(square, W)Object methods: getheight, getnhood, getsequence, isflat, reflect, translateDilating or Eroding an Image SE = strel(square,3); BW2 = imdilate(BW,SE); or BW2 = imerode(BW1
46、,SE);Combining Dilation and Erosion Morphological opening: erode then dilate Skeletonization: BW2 = bwmorph(BW1,skel,Inf); Perimeter determination確定周界: BW2 = bwperim(BW1); 其它:bwhitmiss(binary hit-miss operation),imclose,imopen,imtophat(top-hat filtering),imbothat(bottom-hat filtering)Morphological R
47、econstruction 形態重構Morphological reconstruction is based on morphological dilation, but its processing:based on two images, a marker and a mask, rather than one image and a structuring element.based on the concept of connectivity, rather than a structuring element.repeats until stability; i.e., the i
48、mage no longer changes.Pixel Connectivity2-D Connectivities4-connectedPixels are connected if their edges touch. This means that a pair of adjoining pixels are part of the same object only if they are both on and are connected along the horizontal or vertical direction.8-connectedPixels are connecte
49、d if their edges or corners touch. This means that if two adjoining pixels are on, they are part of the same object, regardless of whether they are connected along the horizontal, vertical, or diagonal direction.3-D Connectivities6-connectedPixels are connected if their faces touch.18-connectedPixel
50、s are connected if their faces or edges touch.26-connectedPixels are connected if their faces, edges, or corners touch.Custom Connectivities: define custom neighborhoods by specifying a 3-by-.-by-3 array of 0s and 1s.Flood-Fill Operationsimfill(BW,4 3,8) % 4 3-Specifying the Starting Point, 8-Specif
51、ying ConnectivityI1 = imfill(I,holes); % Filling HolesFinding Peaks and Valleysimregionalmaximregionalminidentify all regional minima or maximaimextendedmaximextendedminidentify regional minima or maxima that are greater than or less than a specified thresholdimhmaximhminremove the less significant
52、minima and maxima but retain the significant minima and maximaimimposeminemphasize specific minima (dark objects) in an imageDistance Transform 距離變換bwdist: Distance transform of binary imageD給出BW每一像素離其最近非零像素的距離,L則是對應非零像素的一維下標D = bwdist(BW)D,L = bwdist(BW)D,L = bwdist(BW,method) method: Euclidean(def
53、ault),City Block,Chessboard,Quasi-EuclideanLabeling and Measuring Objects in a Binary ImageLabeling Objects in a Binary Imagebwconncomp computes connected components BW=logical(zeros(8,9); BW(2:4,2:3)=1 BW(5:7,5:6)=1 BW(2:3,7:9)=1, BW(3,7)=0 cc = bwconncomp(BW) Connectivity: 8ImageSize: 8 9NumObject
54、s: 3PixelIdxList: 6x1 double 6x1 double 5x1 doublelabelmatrix construct a label matrix labeled = labelmatrix(cc)Original imageLabeled image illustrationbwlabel, bwlabeln: 過時的函數,效果同bwconncompSelecting Objects in a Binary Image imshow(BW) BW2 = bwselectFinding the Area of the Foreground of a Binary Im
55、age bwarea(BW) % = 17.1250Finding the Euler Number of a Binary Image歐拉數: the total number of objects in the image minus the number of holes in those objectsbweuler(BW) % = 3Lookup Table Operations lut = makelut(fun,n) % makelut creates lookup tables for 2-by-2 and 3-by-3 neighborhoods BW2 = applylut
56、(BW1,lut);Analyzing and Enhancing Images 圖像分析和增強Getting Information about Image Pixel Values and Image StatisticsGetting Image Pixel Values Using impixelCreating an Intensity Profile of an Image Using improfileDisplaying a Contour Plot of Image Data C,h=imcontour(I,3); % Create contour plot of image
57、 data clabel(C,h) % Contour plot elevation labelsCreating an Image Histogram Using imhistGetting Summary Statistics About an Imagemean2, std2, and corr2(相關系數,對應一維的corrcoef)Computing Properties for Image Regionsregionprops:Measure properties of image regionsAnalyzing ImagesDetecting Edges Using the e
58、dge Function 邊緣檢測sobel,prewitt,robertslog(Laplacian of Gaussian method),zerocrosscanny(for weak edges)Detecting Corners Using the cornermetric Function C = cornermetric(I, SensitivityFactor, 0.24); corner_peaks = imregionalmax(C); imshow(I); y, x = find(corner_peaks); hold on, plot(x, y, r.), hold o
59、ffTracing Object Boundaries in an Image 物體邊緣追蹤bwtraceboundarybwboundariesDetecting Lines Using the Hough Transform 直線檢測houghhoughpeakshoughlinesAnalyzing Image Homogeneity Using Quadtree DecompositionS = qtdecomp(I,0.27); % S大小與I相同,數據類型為double,屬性為sparseAnalyzing the Texture of an Image 紋理分析Using Tex
60、ture Filter FunctionsrangefiltstdfiltentropyfiltUsing a Gray-Level Co-Occurrence Matrix (GLCM)graycomatrix: calculating how often a pixel with the gray-level value i occurs in a specific spatial relationship to a pixel with the value jgraycoprops: Properties of gray-level co-occurrence matrixAdjusti
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《汽車維護》課件全套 模塊1-5 汽車發動機系統的檢查與維護 -威朗汽車單人快速維護作業
- 2022年焦作大學自考英語(二)練習題(附答案解析)
- 《連鎖門店店長管理實務》課件項目8門店績效評價
- 《醫學英語視聽說第二版》課件unit5
- 2025年國際經濟與貿易實務考試卷及答案
- 《連鎖經營》課件項目六連鎖
- 2025年高考英語科目模擬試卷及答案
- 2025年城市社區建設與管理考試試題及答案
- 浙江省金華、麗水市2025屆八下英語期末達標檢測試題含答案
- 醫院感染爆發知識培訓
- 2025年高考軍隊院校征集和招錄人員政治考核表(原表)
- TCCEAS001-2022建設項目工程總承包計價規范
- 2024年河北省物理組招生計劃
- 建筑工程聯營合作協議(合同)
- 利樂灌裝保養執行
- 法人委托書范本
- 最新版焊接工藝評定格式標準
- 【圖文】泵用密封沖洗方案演示圖
- 新世紀大學英語綜合教程4 Unit1
- 振型中的節點,節線,節徑和節圓
- 虹鱒魚養殖項目可行性研究報告寫作范文
評論
0/150
提交評論