《人工智能視覺應用開發(fā)(雙語)》課件-任務8 Canny技術找出圖像輪廓_第1頁
《人工智能視覺應用開發(fā)(雙語)》課件-任務8 Canny技術找出圖像輪廓_第2頁
《人工智能視覺應用開發(fā)(雙語)》課件-任務8 Canny技術找出圖像輪廓_第3頁
《人工智能視覺應用開發(fā)(雙語)》課件-任務8 Canny技術找出圖像輪廓_第4頁
《人工智能視覺應用開發(fā)(雙語)》課件-任務8 Canny技術找出圖像輪廓_第5頁
已閱讀5頁,還剩23頁未讀 繼續(xù)免費閱讀

付費下載

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

任務8-Canny技術找出圖像輪廓2024-07-20Task8-CannytechnologytofindtheimageoutlineCanny算法的應用ApplicationofCannyalgorithmCanny算法的原理TheprincipleofCannyalgorithm圖像輪廓檢測的實現(xiàn)步驟Theimplementationstepsofimagecontourdetection代碼實現(xiàn)Codeimplementation總結Summary目錄CATALOGUEPART01Canny算法的ApplicationofCannyalgorithmCanny算法在圖像處理中的作用TheroleofCannyalgorithminimageprocessingCanny算法是計算機視覺領域中常用的邊緣檢測方法,它能夠準確地找出圖像中的輪廓區(qū)域。Cannyalgorithmisacommonlyusededgedetectionmethodinthefieldofcomputervision,whichcanaccuratelyfindoutthecontourregionintheimage.Canny算法的優(yōu)勢AdvantagesoftheCannyalgorithmCanny算法具有抗噪聲能力強、定位準確等特點,適用于各種復雜的圖像環(huán)境。Cannyalgorithmhasthecharacteristicsofstronganti-noiseability,accuratepositioning,etc.,whichissuitableforavarietyofcompleximageenvironments.Canny算法的應用TheapplicationofCannyalgorithmPART02Canny算法的原理HowtheCannyalgorithmworksCanny算法是一種基于梯度的邊緣檢測算法,具有抗噪聲能力強、定位準確等特點。Cannyalgorithmisagradient-basededgedetectionalgorithm,whichhasthecharacteristicsofstronganti-noiseabilityandaccuratepositioning.Canny算法CannyalgorithmCanny算法的主要步驟包括高斯濾波、計算梯度幅值和方向、非極大值抑制以及雙閾值處理。ThemainstepsoftheCannyalgorithmincludeGaussianfiltering,calculatingthegradientamplitudeanddirection,non-maximumsuppression,anddoublethresholdprocessing.邊緣檢測EdgeDetection高斯濾波使用一個高斯核對圖像進行卷積操作,能夠有效地減少噪聲的影響。GaussianfilteringusesaGaussiancheckimageforconvolutionoperation,whichcaneffectivelyreducetheinfluenceofnoise.高斯濾波GaussianfilteringCanny算法概述Cannyalgorithmoverview010203Canny算法概述Cannyalgorithmoverview梯度計算GradientComputing對平滑后的圖像計算梯度,常用的梯度算子有Sobel算子和Prewitt算子。SobeloperatorandPrewittoperatorarecommonlyusedtocalculatethegradientofthesmoothedimage.非極大值抑制Non-maximumsuppression根據(jù)梯度方向,對圖像進行非極大值抑制,選擇局部最大值作為邊緣像素。Accordingtothegradientdirection,non-maximumsuppressionisappliedtotheimage,selectingthelocalmaximumastheedgepixel.雙閾值處理Doublethresholdprocessing將梯度幅值進行閾值分割,得到強邊緣和弱邊緣,便于后續(xù)的邊緣連接。Thegradientamplitudeissegmentedbythresholdtogetstrongedgeandweakedge,whichisconvenientforsubsequentedgeconnection.邊緣連接Edgejoining根據(jù)強邊緣像素的鄰域信息,將弱邊緣連接到強邊緣,形成閉合的邊緣輪廓。Accordingtotheneighborhoodinformationofthestrongedgepixels,theweakedgeisconnectedtothestrongedgetoformaclosededgeoutline.高斯核GaussianKernel高斯核是一個重要的概念,它決定了高斯濾波的效果。核的大小和標準差需要根據(jù)具體情況進行調(diào)整。GaussiankernelisanimportantconceptthatdeterminestheeffectofGaussianfiltering.Thesizeandstandarddeviationofthekernelneedtobeadjustedaccordingtothespecificsituation.高斯濾波Gaussianfiltering高斯濾波使用一個高斯核對圖像進行卷積操作,能夠有效地減少噪聲的影響。GaussianfilteringusesaGaussiancheckimageforconvolutionoperation,whichcaneffectivelyreducetheinfluenceofnoise.平滑圖像Smoothingtheimage高斯濾波旨在平滑圖像并抑制噪聲,從而為后續(xù)的邊緣檢測步驟提供更好的基礎。Gaussianfilteringisdesignedtosmooththeimageandsuppressnoise,thusprovidingabetterbasisforsubsequentedgedetectionsteps.高斯濾波Gaussianfiltering對平滑后的圖像計算梯度,常用的梯度算子有Sobel算子和Prewitt算子。SobeloperatorandPrewittoperatorarecommonlyusedtocalculatethegradientofthesmoothedimage.梯度計算GradientcalculationSobel算子和Prewitt算子是兩種常用的梯度算子,通過對圖像在水平和垂直方向上應用這些算子進行卷積操作,得到圖像的梯度幅值和方向。SobeloperatorandPrewittoperatoraretwocommonlyusedgradientoperators.Thegradientamplitudeanddirectionoftheimagecanbeobtainedbyapplyingtheseoperatorstotheconvolutionoperationonthehorizontalandverticaldirectionsoftheimage.梯度算子Gradientoperators梯度計算Gradientcalculation非極大值抑制Non-maximumsuppression插值操作Interpolationoperation在梯度方向上進行插值操作,選擇局部最大值作為邊緣像素,并抑制非邊緣像素,能夠更好地定位圖像中的邊緣區(qū)域。Interpolatinginthegradientdirection,selectingthelocalmaximumastheedgepixel,andsuppressingthenon-edgepixel,enablesbetterpositioningoftheedgeregionintheimage.非極大值抑制Non-maximumsuppression根據(jù)梯度方向,對圖像進行非極大值抑制,通過在梯度方向上進行插值操作,選擇局部最大值作為邊緣像素,并抑制非邊緣像素。Accordingtothegradientdirection,non-maximumsuppressionisappliedtotheimagebyperforminganinterpolationoperationinthegradientdirection,selectingthelocalmaximumastheedgepixel,andsuppressingthenon-edgepixel.雙閾值處理Doublethresholdprocessing將梯度幅值進行閾值分割,得到強邊緣和弱邊緣,通常將梯度幅值大于高閾值的像素判定為強邊緣,將梯度幅值介于低閾值和高閾值之間的像素判定為弱邊緣。Thegradientamplitudeisdividedbythresholdtogetstrongedgeandweakedge,usuallythepixelwhosegradientamplitudeisgreaterthanthehighthresholdisjudgedasastrongedge,andthepixelwhosegradientamplitudeisbetweenthelowthresholdandthehighthresholdisjudgedasaweakedge.梯度幅值分割Gradientamplitudesegmentation通過閾值分割,能夠將圖像中的梯度幅值進行區(qū)分,得到強邊緣和弱邊緣,從而更好地提取出圖像中的輪廓信息。Throughthresholdsegmentation,thegradientamplitudeintheimagecanbedistinguishedtogetstrongedgeandweakedge,soastobetterextractthecontourinformationintheimage.雙閾值處理Doublethresholdprocessing邊緣連接Edgejoin根據(jù)強邊緣像素的鄰域信息,將弱邊緣連接到強邊緣,形成閉合的邊緣輪廓。Accordingtotheneighborhoodinformationofthestrongedgepixels,theweakedgeisconnectedtothestrongedgetoformaclosededgeoutline.鄰域信息Neighborhoodinformation利用鄰域信息,將弱邊緣連接到強邊緣,能夠更好地形成閉合的邊緣輪廓。Byusingtheneighborhoodinformation,theweakedgeisconnectedtothestrongedge,andtheclosededgeprofilecanbebetterformed.邊緣連接EdgeJoiningPART03圖像輪廓檢測的實現(xiàn)步驟Theimplementationstepsofimagecontourdetection在Python中,可以使用OpenCV庫等進行圖像處理,通過導入相關的庫,可以使用Canny函數(shù)進行圖像邊緣檢測。InPython,youcanuseOpenCVlibraryforimageprocessing,byimportingrelatedlibraries,youcanuseCannyfunctionforimageedgedetection.導入OpenCV庫ImportOpenCVlibraryOpenCV庫中的Canny函數(shù)是一種常用的邊緣檢測算法,通過導入OpenCV庫,可以方便地使用Canny函數(shù)進行圖像邊緣檢測。CannyfunctioninOpenCVlibraryisacommonlyusededgedetectionalgorithm,byimportingOpenCVlibrary,youcaneasilyuseCannyfunctionforimageedgedetection.Canny函數(shù)進行邊緣檢測Cannyfunctionforedgedetection導入相關的庫Importtherelevantlibraries讀取圖像Readimages使用圖像讀取函數(shù)將圖像讀入內(nèi)存,方便進行后續(xù)的圖像處理操作。Usetheimagereadfunctiontoreadtheimageintomemoryforeasysubsequentimageprocessingoperations.轉換灰度圖像Convertgrayscaleimages讀取圖像并轉化為灰度圖像Readtheimageandtransformitintoagrayscaleimage將彩色圖像轉換為灰度圖像,是因為Canny算法是基于灰度圖像的操作,轉換后能更好地適應算法要求。ThecolorimageisconvertedtoagrayscaleimagebecausetheCannyalgorithmisbasedontheoperationofthegrayscaleimage,whichcanbetteradapttothealgorithmrequirementsafterconversion.0102高斯濾波Readimages對轉化后的灰度圖像進行高斯濾波操作,以平滑圖像并抑制噪聲。Usetheimagereadfunctiontoreadtheimageintomemoryforeasysubsequentimageprocessingoperations.高斯濾波器Convertgrayscaleimages高斯濾波使用一個高斯核對圖像進行卷積操作,它能夠有效地減少噪聲的影響。ThecolorimageisconvertedtoagrayscaleimagebecausetheCannyalgorithmisbasedontheoperationofthegrayscaleimage,whichcanbetteradapttothealgorithmrequirementsafterconversion.高斯濾波ReadtheimageandtransformitintoagrayscaleimageVS對平滑后的圖像計算梯度,常用的梯度算子有Sobel和Prewitt。Forcalculatingthegradientofthesmoothedimage,commongradientoperatorsareSobelandPrewitt.梯度幅值和方向Gradientamplitudeanddirection通過卷積操作得到圖像的梯度幅值和方向,用于后續(xù)邊緣檢測。Thegradientamplitudeanddirectionoftheimageareobtainedthroughtheconvolutionoperationforsubsequentedgedetection.梯度計算Gradientcalculation計算梯度幅值和方向Readtheimageandtransformitintoagrayscaleimage根據(jù)梯度方向,對圖像進行非極大值抑制,選擇局部最大值作為邊緣像素。Accordingtothegradientdirection,non-maximumsuppressionisappliedtotheimageandthelocalmaximumvalueisselectedastheedgepixel.非極大值抑制Non-maximumsuppression在梯度方向上進行插值操作,抑制非邊緣像素,提高邊緣檢測的準確性。Theinterpolationoperationiscarriedoutinthegradientdirectiontosuppressnon-edgepixelsandimprovetheaccuracyofedgedetection.插值操作Interpolatingoperation非極大值抑制Non-maximumsuppression雙閾值處理Doublethresholdprocessing邊緣判定EdgeDecision像素梯度幅值大于高閾值的為強邊緣,介于低閾值和高閾值之間的為弱邊緣。Thepixelgradientamplitudelargerthanthehighthresholdisastrongedge,andthepixelgradientamplitudebetweenthelowthresholdandthehighthresholdisaweakedge.雙閾值處理Doublethresholdprocessing將梯度幅值進行閾值分割,得到強邊緣和弱邊緣。Thegradientamplitudeissegmentedbythresholdtogetstrongedgeandweakedge.強邊緣像素Strongedgepixels根據(jù)強邊緣像素的鄰域信息,將弱邊緣連接到強邊緣,形成閉合的邊緣輪廓。Basedontheneighborhoodinformationofthestrongedgepixels,connecttheweakedgetothestrongedgetoformaclosededgeoutline.弱邊緣連接WeakedgeJoining弱邊緣連接強邊緣,需找到強邊緣像素的鄰域,將符合條件的弱邊緣像素連接到強邊緣上。Toconnecttheweakedgetothestrongedge,itisnecessarytofindtheneighborhoodofthestrongedgepixelandconnectthequalifiedweakedgepixeltothestrongedge.邊緣輪廓提取Edgecontourextraction通過連接弱邊緣和強邊緣,可以提取出完整的邊緣輪廓,用于后續(xù)的目標識別和圖像分割。Byconnectingweakedgesandstrongedges,acompleteedgecontourcanbeextractedforsubsequenttargetrecognitionandimagesegmentation.邊緣連接EdgeJoining使用圖像顯示函數(shù)將原始圖像進行顯示,以便與檢測到的邊緣圖像進行對比。Usetheimagedisplayfunctiontodisplaytheoriginalimageforcomparisonwiththedetectededgeimage.原始圖像顯示RawimageDisplay使用圖像顯示函數(shù)將檢測到的邊緣圖像進行顯示,突出輪廓檢測的結果。Usetheimagedisplayfunctiontodisplaythedetectededgeimageandhighlighttheresultofthecontourdetection.邊緣圖像顯示Edgeimagedisplay通過原始圖像和邊緣圖像的對比顯示,可以清晰地看到輪廓檢測的效果。Theeffectofcontourdetectioncanbeclearlyseenthroughthecontrastdisplayoftheoriginalimageandtheedgeimage.對比顯示Contrastdisplay顯示結果ShowresultsPART04代碼實現(xiàn)CodeImplementation代碼實現(xiàn)Codeimplementation導入所需的庫Importtherequiredlibrary在Python中,使用OpenCV庫進行圖像處理,通過導入相關庫,使用Canny函數(shù)進行圖像邊緣檢測。InPython,usetheOpenCVlibraryforimageprocessing,andusetheCannyfunctionforimageedgedetectionbyimportingrelatedlibraries.讀取并轉換圖像Readandconverttheimage對圖像進行高斯濾波Gaussianfiltertheimage使用圖像讀取函數(shù)將圖像讀入內(nèi)存,將彩色圖像轉換為灰度圖像,因為Canny算法是基于灰度圖像的操作。TheimageisreadintomemoryusingtheimagereadfunctiontoconvertthecolorimagetoagrayscaleimagebecausetheCannyalgorithmisanoperationbasedongrayscaleimages.對轉化后的灰度圖像進行高斯濾波操作,以平滑圖像并抑制噪聲。TheconvertedgrayscaleimageisoperatedbyGaussianfilteringtosmooththeimageandsuppressthenoise.計算梯度幅值和方向Calculatethegradientamplitudeanddirection使用Canny函數(shù)對平滑后的圖像進行梯度計算,得到圖像的梯度幅值和方向。TheCannyfunctionisusedtocalculatethegradientofthesmoothedimagetoobtainthegradientamplitudeanddirectionoftheimage.代碼實現(xiàn)Codeimplementation進行非極大值抑制Donon-maximumsuppression根據(jù)梯度方向,對圖像進行非極大值抑制操作,選擇局部最大值作為邊緣像素。Accordingtothegradientdirection,performanon-maximumsuppressoperationontheimage,selectingthelocalmaximumastheedgepixel.對梯度幅值進行雙閾值處理Thegradientamplitudeisprocessedbydoublethreshold對梯度幅值進行雙閾值處理,將梯度幅值大于高閾值的像素判定為強邊緣,介于低閾值和高閾值之間的像素判定為弱邊緣。Thegradientamplitudeisdouble-thresholdprocessed,andthepixelswhosegradientamplitudeislargerthanthehighthresholdarejudgedasstrongedges,andthosebetweenthelowthresholdandthehighthresholdarejudgedasweakedges.根據(jù)強邊緣像素的鄰域信息,將弱邊緣連接到強邊緣,形成閉合的邊緣輪廓。Accordingtotheneighborhoodinformationofthepixelswithstrongedges,theweakedgesareconnectedtothestrongedgestoformaclosededgeprofile.根據(jù)鄰域信息連接邊緣Connectedgesbasedonneighborhoodinformation使用圖像顯示函數(shù)將圖像進行顯示,可以將原始圖像和檢測到的邊緣圖像進行對比顯示。Usingtheimagedisplayfuncti

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論