How to find the center position under the saturation spot signal
4 ビュー (過去 30 日間)
古いコメントを表示
Hello, I would like to seek your help. I have an image below. How can I find the spot position centre (X,Y) under the saturation spot signal?
The code as below
clear all; close all;clc
D = 'C:\Users\Admin\Desktop';
S = dir(fullfile(D,'*.bmp')); % pattern to match filenames.
%%-------open file----
S_BG = dir(fullfile(D,'figure.bmp')); % pattern to match filenames.
for k_BG = 1:numel(S_BG)
F_BG = fullfile(D,S_BG(k_BG).name);
I_BG = imread(F_BG);
Z = im2double(I_BG);
Z = rgb2gray(Z);
figure(100),imshow(Z)
figure(101)
surf(Z)
end
0 件のコメント
採用された回答
Steve Eddins
2021 年 4 月 9 日
Try converting the image to binary using imbinarize and then using regionprops to compute the centroid.
rgb = imread('image.bmp');
I = rgb2gray(rgb);
bw = imbinarize(I);
s = regionprops(bw,'Centroid')
imshow(I,'InitialMagnification','fit')
hold on
plot(s.Centroid(1),s.Centroid(2),'b*')
hold off
Alternatively, consider computing a weighted centroid using the grayscale pixel values. First, expand the binarized object using dilation to include more of the grayscale pixel values at the edge of the object.
bw2 = imdilate(bw,strel('disk',20));
s2 = regionprops(bw2,I,'WeightedCentroid')
imshow(I,'InitialMagnification','fit')
hold on
plot(s2.WeightedCentroid(1),s2.WeightedCentroid(2),'b*')
hold off
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!