You can use binary image operations in Matlab to obtain centroids of dots with a gray area. With centroids, you can do anything with them, for example. fitting lines. This is one example based on your image of how this can be done.
% convert rgb to gray scale
im = rgb2gray(imread('layer.jpg'));
% mask of gray-color with points
bwMask1 = im < 100;
% mask with points only
bwMask2 = im < 20;
% remove points outside gray area
bwMask3 = bwareaopen(bwMask1, 400);
% points only withing gray ![enter image description here][1]area
bwMask4 = bwMask2 & ~(bwMask3 - bwMask2);
% label all points
[L] = bwlabel(bwMask4, 8);
% calculate points parameters
pointStats = regionprops(L);
% get centroids of each point
pointCentroidsCell = {pointStats(:).Centroid};
pointCentroidsMat = vertcat(pointCentroidsCell{:});
%plot results:
RGB = label2rgb(L);
figure, imshow(RGB); title('labeled points');
![enter image description here][2]
figure,imshow(im); hold on;
plot(pointCentroidsMat(:, 1), pointCentroidsMat(:, 2), 'r*');
title('Found centroinds');


source
share