I1 = imread('images\imgc1.jpg');
Ibw = im2bw(I1);
Ibw = imfill(Ibw,'holes');
Ilabel = bwlabel(Ibw);
stat1 = regionprops(~Ilabel,'centroid');
imshow(I1); hold on;
for x = 1: numel(stat1)
plot(stat1(x).Centroid(1),stat1(x).Centroid(2),'ro');
end
The variable 'stat' contains the values of xy axis of centroid. I only need the y axis value.
Typing stat(2) does not help.