Applying Gaussian Mixture Models to grayscale images
4 views (last 30 days)
Show older comments
Suppose I have a grayscale image such as imshow('rice.png') and I want to cluster the grains using Gaussian Mixture Models (gmdistribution).
Is there any better way to do it than generating a location matrix of high intensity coordinates and applying gmdistribution.fit? Or is there a matlab filter that will automatically transform grayscale/intensity data into data needed for fitting a Gaussian mixture model in matlab?
thanks
0 Comments
Answers (1)
Image Analyst
on 29 Jan 2017
If you want to cluster the location of the grain centroids, then find the centroids with regionprops, and then call fitgmdist()
binaryImage = grayImage > somethreshold;
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Centroid');
allCentroids = [props.Centroid];
xCentroids = allCentroids(1:2:end);
yCentroid = allCentroids(2:2:end);
% Plot centroids over the displayed image
hold on;
plot(xCentroids, yCentroids, 'r+', 'MarkerSize', 20, 'LineWidth', 2);
Then call fitgmdist():
GMModel = fitgmdist([xCentroids, yCentroids], numClusters);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!