image analysis using kmeans

1 vue (au cours des 30 derniers jours)
Sara Anis
Sara Anis le 2 Juil 2019
Réponse apportée : Satwik le 21 Avr 2025
Hi, I have a .hdf image that i need to analyse. The image has two spots on it that i need to be able to select and compare the intensity of. I first tried to use kmeans clustering and the insegkmeans function but still ran into problems finding the x,y centers of the spots and being able to select that cluster to compare. Can someone please help me.

Réponses (1)

Satwik
Satwik le 21 Avr 2025
Here is an workflow which can be used for analyzing two points in a .HDF image.
1. Load the HDF Image:
img = h5read('your_image.hdf', '/ImageData'); % Adjust dataset name as needed
img = squeeze(img); % Remove singleton dimensions
img = double(img);
2. Segment the Spots with K-means:
[idx, C] = kmeans(img(:), 2);
clusters = reshape(idx, size(img));
spotMask = clusters == find(C == max(C)); % Assume brighter spots
3. Find Centers and Intensities:
props = regionprops(spotMask, img, 'Centroid', 'MeanIntensity');
imshow(img, []); hold on;
for k = 1:length(props)
plot(props(k).Centroid(1), props(k).Centroid(2), 'r+', 'MarkerSize', 15);
fprintf('Spot %d: Intensity %.2f\n', k, props(k).MeanIntensity);
end
hold off;
I hope this helps!

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by