clustering based on area

3 次查看(过去 30 天)
i already measured the area on my sputum cell. now i want to cluster it based on area. area >2000 in figure 1 and area 2000< is in other figure 2. can i know the simple tutorial.? i dont want to use k mean clustering because it very complicated. i only want to cluster them as simple as i can
  4 个评论
martin SALGADO
martin SALGADO 2015-11-12
Your code Image Segmentation Tutorial is for segment images, but I want only one way clustering a set of points, and the area that contains the items is less than some value.

请先登录,再进行评论。

采纳的回答

wil
wil 2015-3-24
Hi, I've looked at the code and I've worked out what you need. Before your final loop "% Loop over all blobs printing their measurements to the command window", add the line
vols = zeros(1,numberOfBlobs); % create list to contain cell areas
and then at the end of the loop (before end), simply add
vols(k) = blobArea; % add area to vols
Then, the code you require to plot two images (one for the smaller, one for the bigger) as binary images. The lists idxs_1 and idx_2 contain the indexes for the cells belonging to each group. You can use this to add more qualifiers, and create different groups if you need to.
idxs_1 = find(vols < 2000); % indexes of vols that are lower than 2000
idxs_2 = find(vols >= 2000);
cells_1 = zeros(size(hImage)); % create blank binary images
cells_2 = zeros(size(hImage));
for i = 1:numel(idxs_1) % add small blobs to image 1
cells_1(blobMeasurements(idxs_1(i)).PixelIdxList) = 1;
end
for i = 1:numel(idxs_2) % add larger blobs to image 2
cells_2(blobMeasurements(idxs_2(i)).PixelIdxList) = 1;
end
% display
figure(4), subplot (2,2,1), imshow(cells_1,[]);
figure(4), subplot (2,2,2), imshow(cells_2,[]);
I hope this solves your problem.
Cheers, Wil
  2 个评论
izyan hanum
izyan hanum 2015-3-24
yes sir.............. that i want sir..... im very happy now... thank you may god bless you..
Image Analyst
Image Analyst 2018-3-2
It's simpler to just use bwareafilt().

请先登录,再进行评论。

更多回答(2 个)

wil
wil 2015-3-23
Hi,
k-means is probably the simplest method of clustering, but if you simply want to sort the regions based on their area, you can use logical indexing or the find() method.
It depends on they type of data your groups are, but if they are simply binary images you can use (assuming the cells are contained in a cell, change as appropriate)
vol = cells{i};
area(i) = numel(vol(vol ~= 0));
to get the area for each cell and sort them using
idxs_1 = find(area < 2000);
idxs_2 = find(area >= 2000);
cells_1 = cells(idxs_1);
cells_2 = cells(idxs_2);
The groups cells_1 and cells_2 now contain your grouped cells.
Hope this helps, let me know if anything needs clarifying.
Wil

izyan hanum
izyan hanum 2015-3-23
i dont know how to send the code here using microsoft
  1 个评论
izyan hanum
izyan hanum 2015-3-23
https://word.office.live.com/wv/WordView.aspx?FBsrc=https%3A%2F%2Fwww.facebook.com%2Fattachments%2Ffile_preview.php%3Fid%3D734274853338438%26time%3D1427127122%26metadata&access_token=100003736390577%3AAVKwfhY8Bg_OXG_qYVHRh4hByGWdBCkH8QqLBSW3UOoxzQ&title=Try+thresholding+in+HSV+color+space+to+get+purple+blobs+but+not+black+blobs+or+yellow+background.docx

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Clusters and Clouds 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by