資源簡(jiǎn)介
matlab環(huán)境下,能夠求取光斑中心,并讀入txt中
代碼片段和文件信息
clear;
clc;
test_im=imread(‘E:\實(shí)驗(yàn)\47cm7月2日\(chéng)靶-3\Y?5\5?(18).bmp‘);?%原始圖像(黑色背景,白色圓點(diǎn))
test_im_gray=rgb2gray(test_im);
[mn]=size(test_im_gray);
bw(1:m1:n)=0;?
for?i=1:m
for?j=1:n
if?test_im_gray(ij)>10;%二值
bw(ij)=1;
end
end
end
L=?bwlabel(bw);
L=imclearborder(L);
L=bwareaopen(L10);%除去多余光點(diǎn)
s?=?regionprops(L?‘centroid‘‘a(chǎn)rea‘?‘boundingbox‘);%求中心
centroids?=?cat(1?s.Centroid)
areas?=?[s.Area];
rects?=?cat(1??s.BoundingBox);
figure;
imshow(test_im);
評(píng)論
共有 條評(píng)論