image analysis using kmeans
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (1)
Satwik
il 21 Apr 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!
0 Commenti
Vedere anche
Categorie
Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!