我想自动提取蓝色附加图像中的标记点,以用于基于点的图像配准。但是由于这些部分来自背景,所以我不知道该如何处理它们。通过我的代码,我可以自动在原始图像与其补码的交集中获得3个最大的连接组件,可以在图像配准中使用它,但是我更喜欢原始图像中带有黑色大圆圈的质心。
A=imread( '1.jpg'); % Original Image
A1=rgb2gray(A); % Convert to grayscale
ABi=imbinarize(A1); % Convert the grayscale image to binary
AF=imfill(ABi,'holes'); % Fill the holes of the binary image
figure(1);
imshow(AF)
AC=imcomplement(ABi); % Invert the filled image
C=intersect(AF,AC); % Intersection of the filled image and the inverted image
intersection = (double(AF) - double(AC)) == 0;
figure(2)
imshow(intersection);
CC = bwconncomp(intersection); % Connected components of the intersect image
stat=regionprops(CC, 'Area','Centroid'); % Calculate properties of the intersect image
area = cat(1, stat.Area);
area_sorted=sort(area,'descend'); % sort areas of the connected components in descending order
centroids = cat(1, stat.Centroid);
centroids_sorted=sort(centroids,'descend');% sort centroids of the connected components in descending order
desired_points= centroids_sorted(1:3,:);