2011-09-04 16 views
3
laListe={{{{10, 17}, 1}, {{33, 12}, 1}, {{32, 17}, 1}, {{9, 10},1}, 
     {{22, 24}, 1},{{27, 6}, 2}, {{25, 13}, 2}, {{30, 9}, 2}}, 
     {{{14, 12}, 1},{{19, 17}, 1}, {{7, 21}, 1}, {{7, 24},1}, 
     {{27, 19}, 1}, {{12, 16}, 2}, {{13, 20}, 2}, {{20, 22}, 2}}} 

FrameXYs = {{4.32, 3.23}, {35.68, 26.75}} 


Row[Function[compNo, 
      Graphics[{White, EdgeForm[Thick], 
      Rectangle @@ FrameXYs, 
      Black, 
      Disk[Sequence @@ laListe[[compNo, #]]] & /@ 
      Range[[email protected][[compNo]]]}, ImageSize -> 300]] /@ 
      {1, 2}] 

enter image description here在數學

聚類2D情節我想找到一種方法來聚集賦予其相互接近這些磁盤。 Mathematica是否有內置功能來做這樣的事情?

編輯

當我試圖FindClusters我還沒有遇到幾個不便之處:

有了:

list1={{{24.413, 6.5978}, {7.68887, 7.2147}, {29.357, 13.2822}, 
     {6.22436, 9.7145}, {22.7162, 17.7198}, {13.6851, 5.7635}, 
     {18.8062, 12.9946}, {8.04889, 16.7414}}} 

是否FindClusters dislkike小數:

FindClusters[Flatten[list1,1]] 

日期:

{{{{24.413, 6.5978}, {7.68887, 7.2147}, {29.357, 13.2822}, 
    {6.22436,9.7145}, {22.7162, 17.7198}, {13.6851, 5.7635}, 
    {18.8062,12.9946}, {8.04889, 16.7414}}}} 

鑑於:

FindClusters[Flatten[Round[list1], 1]] 

日期:

{{{24, 7}, {29, 13}, {23, 18}, {14, 6}, {19, 13}}, 
    {{8, 7}, {6, 10}, {8, 17}}} 

然後,要做到這一點,我不得不擺脫磁盤直徑是視覺集羣對我很重要的。 然後我想捕捉對齊。 5個磁盤沒有分組但對齊。當我在一些作品上測試它時,它並沒有發現這些。

在我想的就是壽「Pointize」使用下面的磁盤:

pointize[{{x_,y_},r_},size_:12] := 
            Table[{x+r Cos[i ((2\[Pi])/size)], 
            y+r Sin[i ((2\[Pi])/size)]},{i,0,size}] 

我用最初計算這些磁盤的ConvexHullArea。我覺得它可以幫助我需要考慮半徑,但實施是棘手的,我甚至不知道它是否相關

此外,我希望它只是小數問題,但我無法使用FindClusters [列表]本身,但必須給它我希望FindClusters [列表,3]的集羣數量,而我想要的是有相同的算法,可以找到不同的組合編號不同的集羣編號。

想一想使用FindClusters的特定設置& /或距離函數嗎?

編輯

我發現了一些有趣的感謝以前的招數這裏學到感謝專家。只是一個想法,我需要找到一種方式來量化,並將新圖像放在矩陣形式中以便使用。

comp1 = Graphics[{White, Rectangle @@ FrameXYs, Black, 
    Disk[Sequence @@ laListe[[1, #]]] & /@ Range[[email protected][[1]]]}, 
    ImageSize -> 300] 

enter image description here

 Binarize[ImageCorrelate[comp1, GaussianMatrix[40]], .95] 

enter image description here

+4

看到我的答案http://stackoverflow.com/questions/3165867/create-a-schedule-detail-of-a-schedule-given-a-list-of-shifts/3251229#3251229 –

+0

我不明白你爲什麼不得不擺脫泡沫直徑 - 它實際上是你的第三個維度,不是嗎?此外,您不必指定要查找的羣集數量。你用Gaussian blob進行的最新編輯很酷,但我認爲這是一個單獨的問題。 – Verbeia

+0

Verbeia,我想我不是敏捷的發現集羣,我認爲我沒有我的第三維(半徑),我會更努力。 – 500

回答

4

或者,您可以使用類似:

Table[Colorize[ 
    MorphologicalComponents[Blur[[email protected], i], .05]], {i, 1, 60, 10}] 

enter image description here

您也可以使用Dilation,這取決於你想要的結果

Table[[email protected] 
    [email protected][[email protected], [email protected]], {i,1,60,10}] 

enter image description here

什麼樣的區域

順便說一句,在這裏你有辦法使用FindClusters,效率不是很高,可能與非直觀的結果:

ImageRotate[Rasterize[ 
    Show[ 
    [email protected] 
    FindClusters[Position[[email protected]@[email protected], 1, {2}], 3], 
    Axes -> False, AspectRatio -> Automatic]], 3 Pi/2] 

enter image description here

編輯

也許你可以管理FindClusters選項獲得更好的結果。例如:

ImageRotate[Rasterize[Show[ 
    [email protected] 
    FindClusters[ 
    Position[[email protected]@Rasterize[[email protected], RasterSize -> 200], 
    1, {2}], 
    3, Method -> {"Agglomerate", "Linkage" -> "Complete"}], 
    Axes -> False, AspectRatio -> Automatic]], 3 Pi/2] 

enter image description here

,從這裏,你還可以去的凸包:

<< ComputationalGeometry` 
fc = FindClusters[ 
     Position[ 
     [email protected]@ 
      Rasterize[[email protected], RasterSize -> 200], 
     1, {2}], 
    3, Method -> {"Agglomerate", "Linkage" -> "Complete"}]; 
ImageRotate[Graphics[[email protected](#[[ConvexHull[#]]]) & /@ fc, Frame->True], 3 Pi/2] 

enter image description here

+0

非常感謝belisarius!最後一個正是我所計算的。像Mr.Wizard&Yoda一樣,我不知道你在做什麼,但每次都是神奇的! – 500

+0

+1,用於使用底層Mathematica系統的許多不同部分的完美實現。 – Verbeia

+0

@Verbeia這正是我發現Mma很好玩的原因 –