, . , , . , , , , , , . . - MATLAB.
, , . 5 , , , , , :
im = imread('http://pages.cs.wisc.edu/~csverma/CS766_09/Stereo/callight.jpg');
im = rgb2gray(im);
im = imclearborder(im);
%
split_point = floor(size(im,2) / 5);
images = mat2cell(im, size(im,1), split_point*ones(5,1));
%
imshow(im);
hold on;
%
for idx = 1 : 5
%
img = images{idx};
%
thresh = img > 200;
%
[y,x] = find(thresh);
%
xmean = mean(x);
ymean = mean(y);
%
%
plot(xmean + (idx-1)*split_point, ymean, 'r.', 'MarkerSize', 18);
end
:

Python, scikit-image numpy matplotlib . Python. , , , balls.jpg:
import skimage.io
import skimage.segmentation
import numpy as np
import matplotlib.pyplot as plt
im = skimage.io.imread('balls.jpg', True)
im_clear = skimage.segmentation.clear_border(im > (200.0/255.0))
split_point = int(im.shape[1]/5)
plt.figure()
plt.imshow(np.dstack([im,im,im]))
for idx in range(5):
img = im_clear[:,idx*split_point:(idx+1)*split_point]
y,x = np.nonzero(img)
xmean = x.mean()
ymean = y.mean()
plt.plot(xmean + idx*split_point, ymean, 'r.', markersize=14)
plt.axis('off')
plt.show()
:

regionprops ( MATLAB, scikit-image ). , regionprops, , , , .
, !