Created
February 22, 2016 09:28
-
-
Save leVirve/a8c5da77df730b23b3ab to your computer and use it in GitHub Desktop.
K-Means on RGB image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
optns = statset('MaxIter', iters); | |
pixels = reshape(img(:), [], 3); | |
[idxs, centroids] = kmeans(pixels, k, 'options', optns); | |
img_map = centroids(idxs, :); | |
img_new = reshape(img_map(:), size(img)); | |
imshow(img_new); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment