clustering based on area

3 visualizzazioni (ultimi 30 giorni)
izyan hanum
izyan hanum il 23 Mar 2015
Commentato: Image Analyst il 2 Mar 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
  4 Commenti
martin SALGADO
martin SALGADO il 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.
izyan hanum
izyan hanum il 3 Dic 2015
you can email me izyanhanum@yahoo.com

Accedi per commentare.

Risposta accettata

wil
wil il 24 Mar 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 Commenti
izyan hanum
izyan hanum il 24 Mar 2015
yes sir.............. that i want sir..... im very happy now... thank you may god bless you..
Image Analyst
Image Analyst il 2 Mar 2018
It's simpler to just use bwareafilt().

Accedi per commentare.

Più risposte (2)

wil
wil il 23 Mar 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
  1 Commento
izyan hanum
izyan hanum il 23 Mar 2015
i run but still have error :( this is my picture

Accedi per commentare.


izyan hanum
izyan hanum il 23 Mar 2015
i dont know how to send the code here using microsoft
  1 Commento
izyan hanum
izyan hanum il 23 Mar 2015
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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by