【正文】
Other variations exist, but Lloyd39。s algorithm is a heuristic for solving the kmeans problem, as with certain binations of starting points and centroids, Lloyd39。s algorithm starts by partitioning the input points into k initial sets, either at random or using some heuristic data. It then calculates the mean point, or centroid, of each set. It constructs a new partition by associating each point with the closest centroid. Then the centroids are recalculated for the new clusters, and algorithm repeated by alternate application of these two steps until convergence, which is obtained when the points no longer switch clusters (or alternatively centroids are no longer changed). Lloyd39。 Machine vision Several generalpurpose algorithms and techniques have been developed for image segmentation. Since there is no general solution to the image segmentation problem, these techniques often have to be bined with domain knowledge in order to effectively solve an image segmentation problem for a problem domain.Clustering methodsThe Kmeans algorithm is an iterative technique that is used to partition an image into K clusters. The basic algorithm is:1. Pick K cluster centers, either randomly or based on some heuristic 2. Assign each pixel in the image to the cluster that minimizes the variance between the pixel and the cluster center 3. Repute the cluster centers by averaging all of the pixels in the cluster 4. Repeat steps 2 and 3 until convergence is attained (. no pixels change clusters) In this case, variance is the squared or absolute difference between a pixel and a cluster center. The difference is typically based on pixel color, intensity, texture, and location, or a weighted bination of these factors. K can be selected manually, randomly, or by a heuristic.This algorithm is guaranteed to converge, but it may not return the optimal solution. The quality of the solution depends on the initial set of clusters and the value of K.In statistics and machine learning, the kmeans algorithm is clustering algorithm to partition n objects into k clusters, where k n. It is similar to the expectationmaximization algorithm for mixtures of Gaussians in that they both attempt to find the centers of natural clusters in the data. The model requires that the object attributes correspond to elements of a vector space. The objective it tries to achieve is to minimize total intracluster variance, or, the squared error function The kmeans clustering was invented in 1956. The most mon form of the algorithm uses an iterative refinement heuristic known as Lloyd39。 Traffic control systems Face recognition Medical Imaging[2] o Locate tumors and other pathologies o Measure tissue volumes o Computerguided surgery o Diagnosis o Treatment planning o Study of anatomical structure 同時也感謝我的同學朋友在此期間給予我的鼓勵和幫助。順利如期的完成本次畢業(yè)設計給了我很大的信心,讓我了解專業(yè)知識的同時也對本專業(yè)的發(fā)展前景充滿信心,但在設計的過程中我也發(fā)現(xiàn)了我的許多不足,理論知識的不扎實,創(chuàng)造性的缺乏使我在設計中吃了不少苦頭,發(fā)現(xiàn)問題就要解決問題,正是我們去更好的研究更好的創(chuàng)造的最大動力,今后我會更加關注本專業(yè)新技術新設備新工藝的出現(xiàn),并爭取盡快的掌握這些先進的知識,在今后的工作中做出更好的成績,更好的為祖國的四化服務。 在理論基礎準備完善后,就是將流程圖程序化,調試程序,作實驗。 設計過程:根據設計題目初步寫出流程圖,由于是首次接觸信息論和圖像處理這方面的知識,在老師的指導下翻閱相關資料,了解所用知識。圖像的目標和背景具有的信息量(即圖像達到理想分割后的區(qū)域)視為最佳信息量,我們需要做的就是尋找能夠將圖像分割后,前后景具有的信息量與最佳信息量相等或是接近的閾值。結論本次論文主要對基于信息熵最大的圖像分割研究,是信息論和圖像處理的一種結合。對下一步的圖像分析打下良好的基礎,滿足要求;但是它對目標細節(jié)處理稍顯不足,尤其是當目標內部色彩分別不大時容易丟失信息。圖412表皮葡萄球菌圖413直方圖圖414信息熵法(Tmax =)圖415經典迭代(Tmax =)圖416 Otsu方法(Tmax =99)實驗圖像4:原始圖像如圖417所示,圖像直方圖如圖418所示,圖419為基于最大信息熵法圖像分割圖,圖420為經典迭代法圖像分割圖,圖421為otsu法圖像分割圖。 圖42大腸埃希菌圖43直方圖圖44信息熵法(Tmax=)圖45經典迭代(Tmax =)圖46Otsu方法(Tmax =97)實驗圖像2:原始圖像如圖47所示,圖像直方圖如圖48所示,圖49為基于最大信息熵法圖像分割圖,圖410為經典迭代法圖像分割圖,圖411為otsu法圖像分割圖。imshow(I)。 else I(i,j)=1。V_min=min(min(I))。end[X,Y]=size(I)。)。 I=imread(39。(3) Otsu方法程序:clear。 else I(i,j)=1。 T=Tnext。 Tnext=*(mean(I(g))+mean(I(~g)))。 %初始分割閾值done=false。end[X,Y]=size(I)。)。 I=imread(39。 %輸出圖像(2)經典迭代法程序:clear。 else I(i,j)=1。 H0=H1。 break。 cout=cout1。 %計算分割后區(qū)域G1的信息熵Hb=sum(grayp(TT+(find(grayp(TT+1:end)0)))/grayPb.*log(grayp(TT+(find(grayp(TT+1:end)0)))/grayPb))。 if grayPb==0 grayPb=eps。 %計算分割區(qū)域G1的概率和 if grayPd==0 grayPd=eps。 TT=round(T2)。 M2=B2/A2。 B2=B2+I(i,j)。 B1=B1+I(i,j)。 B2=0。 A2=0。 T1=T0。 Hd=0。 %初始化grayPd=0。cout=100。 %求圖像像素概率 I=double(I)。 %計算圖像直方圖figure,plot(h)。T0=(V_max+V_min)/2。V_max=max(max(I))。 %顯示圖像if length(size(I))==3 %如果是彩色圖像轉換為灰度圖像 I=rgb2gray(I)。39。close all。但圖像信息熵得到最大保留。取新的閾值: (41)4) 根據分割圖像,分別求出對象與背景的信息熵和Hb,比較與+,如果與+相等或者相差在規(guī)定的范圍內,或者達到規(guī)定的迭代次數(shù),則可將作為最終閾值結果,否則將賦給將+賦給,重復2到4步的操作,直至滿足要求。2) 根據將圖像分為和兩部分,灰度大于的像素組成區(qū)域,灰度小于的像素組成區(qū)域。我們相信,在不斷使用中,讀者會發(fā)現(xiàn)它的巨大潛力。這種為科學研究著想的設計是通用的編程語言所不及的。 6.方便的繪圖功能 Matlab的繪圖是十分方便的,它有一系列繪圖函數(shù)(命令),例如線性坐標、對數(shù)坐標,半對數(shù)坐標及極坐標,均只需調用不同的繪圖函數(shù)(命令),在圖上標出圖題、XY軸標注,格(柵)繪制也只需調用相應的命令,簡單易行。在此基礎上,高版本的Matlab已逐步擴展到科學及工程計算的其它領域。 5.高效方便的矩陣和數(shù)組運算 Matlab語言象Basic、Fortran和C語言一樣規(guī)定了矩陣的算術運算符、關系運算符、邏輯運算符、條件運算符及賦值運算符,而且這些運算符大部分可以毫無改變地照搬到數(shù)組間的運算,有些如算術運算符只要增加“ 4.語句簡單,內涵豐富 Mat1ab語言中最基本最重要的成分是函數(shù),其一般形式為,即一個函數(shù)由函數(shù)名,輸入變量和輸出變量組成,同一函數(shù)名F,不同數(shù)目的輸入變量(包括無輸入變量)及不同數(shù)目的輸出變量,代表著不同的含義(有點像面向對象中的多態(tài)性。因而,用戶可以根據自己的需要方便地建立和擴充新的庫函數(shù),以便提高Matlab使用效率和擴充它的功能。所以可以說,Mat1ab語言不僅是一種語言,廣義上講是一種該語言開發(fā)系統(tǒng),即語言調試系統(tǒng)。又如,將Matlab源程序編輯為M文件,由于Mat1ab磁盤文件也是M文件,所以編輯后的源文件就可直接運行,而不需進行編譯和連接。它能在同一畫面上進行靈活操作快速排除輸入程序中的書寫錯誤、語法錯誤以至語意錯誤,從而加快了用戶編寫、修改和調試程序的速度,可以說在編程和調試過程中它是一種比VB還要簡單的語言。各個步驟之間是順序關系,編程的過程就是在它們之間作瀑布型的循環(huán)。 2.用戶使用方便 Matlab語言是一種解釋執(zhí)行的語言(在沒被專門的工具編譯之前),它靈活、方便,其調試程序手段豐富,調試速度快,需要學習時間少。 綜上所述,Matlab語言有如下特點: 1.編程效率高 它是一種面向科學與工程計算的高級語言,允許用數(shù)學形式的語言編寫程序,且比Basic、Fortran和C等語言更加接近我們書寫計算公式的思維方式,用Matlab編寫程序猶如在演算紙上排列出公式與求解問題。 Matlab大大降低了對使用者的數(shù)學基礎和計算機語言知識的要求,而且編程效率和計算效率極高,還可在計算機上直接輸出結果和精美的圖形拷貝,所以它的確為一高效的科研助手。但由于使用Matlab編程運算與人進行科學計算的思路和表達方式完全一致,所以不象學習其它高級語言如Basic、Fortran和C等