title: Automatically detecting clusters in a 2d array/heatmap
body: <p>I have run object detection on a video file and summed the seconds each pixel is activated to find the amount of time an object is shown in this area which gives me a 2d array of time values. Since these objects are in the same position of the video most of the time it leads to some areas of the screen having much higher activation than others. Now I would like to find a way to automatically detect "clusters" without knowing the number of clusters beforehand. I have considered using something like k-means but also read a little about finding local maximums, but I can't quite figure out how to put all this together or which method is the best to go with. Also, the objects vary in size, so I'm not sure I can go with the local maximum method?</p>
  
  <p>The final result would be a list of ids and maximum time value for each cluster.</p>
  
  <pre><code>[[3, 3, 3, 0, 0, 0, 0, 0, 0]
   [3, 3, 3, 0, 0, 0, 2, 2, 2]
   [3, 3, 3, 0, 0, 0, 2, 2, 2]
   [0, 0, 0, 0, 0, 0, 2, 2, 2]]
  </code></pre>
  
  <p>From this example array I would end out with a list:</p>
  
  <pre><code>id | Seconds
  1  |  3
  2  |  2
  </code></pre>
  
  <p>I havn't tried much since I have no clue where to start and any recommendations of methods with code examples or links to where I can find it to accomplish this would be greatly appreciated! :)</p>