What is the best way to find clusters in 2D historgam data?

조회 수: 6 (최근 30일)
Jeff
Jeff 2016년 9월 9일
댓글: Image Analyst 2016년 9월 10일
I want to process GPS path data with overlaid satellite images, but need to select localized areas where desired activities occurred. I can identify the desired areas with histogram2, and am looking for the best approach for clustering the clearly identifiable groupings. Ultimately I want something like the convex hull around each cluster, to identify the extent of the adjacent, non-zero bins for each.

채택된 답변

Image Analyst
Image Analyst 2016년 9월 9일
Just treat the counts matrix like it's an image and use bwconvhull() and regionprops(). Untested code off the top of my head:
binaryImage = countsMatrix > 0;
% Get the convex hull
binaryImage = bwconvhull(binaryImage);
% Identify each individual cluster with an ID number so we can measure it.
[labeledImage, numClusters] = bwlabel(binaryImage);
% Get a list of bins in each cluster by asking regionprops for PixelList
props = regionprops(labeledImage, 'PixelList', 'Centroid');
% Print them out
for k = 1 : numClusters
fprintf('\nBins in cluster #%d = \n', k);
theseBins = props(k).PixelList
fprintf(' x = %d, y = %d\n', theseBins);
end
  댓글 수: 2
Jeff
Jeff 2016년 9월 9일
편집: Jeff 2016년 9월 9일
How about if I wanted to stick to basic commands? I ultimately will create a stand alone for my users and recall something about some of the tool boxes not allowing this. Thks
Image Analyst
Image Analyst 2016년 9월 10일
Well, you're going to have write your own connected components code. You can probably find code on the internet to do that, but it won't be a single line of code like bwlabel() is. Similar for bwconvhull() to get the convex hull of the connected component. You can find convex hull code, but it will be many, many lines of code, not a single line. And finally, you can write your own code to extract the rows and columns of each convex connected component - again many, many lines of code. Good luck though!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Bounding Regions에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by