Define the center of the target in MATLAB

Can anyone suggest alternative ways to detect the center of each of the targets in the following image using MATLBAB:

Goals

My current approach uses area and centroid definitions.

clc,  clear all, close all
format long
beep off
rng('default')

I=imread('WP_20160811_13_38_26_Pro.jpg');


BW=im2bw(I);
BW=imcomplement(BW);

s  = regionprops(BW, 'area','Centroid');

centroids = cat(1, s.Centroid);
imshow(BW)
hold on
plot(centroids(:,1), centroids(:,2), 'b*')
hold off

Is there a more accurate way to detect the center, since this approach seems sensitive to noise, distortion of perspective, etc. Is there a way to find the intersection of each of two quarter circles.

Another type of goal that I am considering is: enter image description here Can someone suggest a way to detect the center of the crosshair? Thanks

+4
source share
1 answer

100% :

I = imadjust(imcomplement(rgb2gray(imread('WP_20160811_13_38_26_Pro.jpg'))));
filtered_BW = bwareaopen(im2bw(I), 500, 4);
% 500 is the area of ignored objects

final_BW = imdilate(filtered_BW, strel('disk', 5));

s  = regionprops(final_BW, 'area','Centroid');
centroids = cat(1, s([s.Area] < 10000).Centroid);
% the condition leaves out the big areas on both sides

figure; imshow(final_BW)
hold on
plot(centroids(:,1), centroids(:,2), 'b*')
hold off

enter image description here

, :

  • rgb2gray !
  • imadjust ,
  • bwareaopen, ,
  • imdilate strel .
+1

Source: https://habr.com/ru/post/1651285/


All Articles