Filter löschen
Filter löschen

Image segmentation using k means clustering

1 Ansicht (letzte 30 Tage)
Penny13
Penny13 am 4 Apr. 2018
Kommentiert: Image Analyst am 22 Dez. 2019
Hello, I have a question and I appreciate your help. I don't know how to use a kmeans clustering results in image segmentation. I have an RGB image of a tissue which has 5 colors for 5 biomarkers and I need to do k means clustering to segment every color in a cluster. Thank you so much for your help.

Akzeptierte Antwort

Image Analyst
Image Analyst am 20 Dez. 2018
Bearbeitet: Image Analyst am 20 Dez. 2018
I'm attaching a color kmeans demo that doesn't require a recent version of the stats toolbox or image processing toolbox.
Personally I don't think kmeans works that great (perhaps because it's untrained), as you'll probably see, and you might try a trained discriminant analysis instead. I attach demos for both.
  1 Kommentar
Penny13
Penny13 am 21 Dez. 2018
Thank you so much Image Analyst. I will try both to see what would be the results.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 4 Apr. 2018
If you have 5 biomarkers then you would need to segment to a minimum of 6 clusters: one for each marker and one for tissue that is not one of the biomarkers. kmeans always assigns a cluster to every point, so if you had a point that was not one of the 5 colors and you asked to cluster it, then it would assign it to one of the five anyhow.
Note that the index values returned by kmeans are not in any pre-set order. You cannot assume that index 1 is associated with biomarker color #1. It is common for clusters to change effective identities during processing, so even if you had specified initial cluster centers in the options you passed to kmeans, you should not assume that the numbering of the output will be the same as the order of the initial cluster centers.
Remember too that a cluster centroid can be outside of data that belongs to that cluster. For example consider a perfect unfilled semi-circle of points: its centroid is the centre of the circle but no data points are at that center. You therefore cannot just index the centroid location into the image and look at the pixel value there to figure out what is happening.
  14 Kommentare
SRUTHI BANDI
SRUTHI BANDI am 22 Dez. 2019
Error in demo1 (line 16)
[cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...
error comes like this
Image Analyst
Image Analyst am 22 Dez. 2019
An error like what? You forgot to give the actual error message.
I just copied and pasted and ran it again successfully.
Are you sure you have the Stats toolbox?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by