clustering based on area
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
izyan hanum
am 23 Mär. 2015
Kommentiert: Image Analyst
am 2 Mär. 2018
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148224/image.png)
4 Kommentare
martin SALGADO
am 12 Nov. 2015
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.
Akzeptierte Antwort
wil
am 24 Mär. 2015
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 Kommentare
Weitere Antworten (2)
wil
am 23 Mär. 2015
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
Siehe auch
Kategorien
Mehr zu Clusters and Clouds finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!