image analysis using kmeans
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Satwik
2025 年 4 月 21 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!