Hi everyone. I'm following the BlobsDemo() by Image Analyst for my personal project. I counted all the blobs and now I want to count the blobs in an image region by using centroids infos. Then, I'd like to display the number of blobs for each image region. So far, after getting the blobs properties, what I did is this:
>>
allBlobCentroids = [blobMeasurements.Centroid];
centroidsX = allBlobCentroids(1:2:end-1);
centroidsY = allBlobCentroids(2:2:end);
Blobs1 = 0;
Blobs2 = 0;
Blobs3 = 0;
Blobs4 = 0;
for k1 = 1 : numberOfBlobs
for j = 1:length(centroidsY)
if 1 < centroidsY(j) < rows/4
Blobs1 = Blobs1 + 1;
else if rows/4+1 < centroidsY(j) < rows/2
Blobs2 = Blobs2 + 1;
else if rows/2 + 1 < centroidsY(j) < 3*rows/4
Blobs3 = Blobs3 + 1;
else if 3*rows/4 + 1 < centroidsY(j) < rows
Blobs4 = Blobs4 + 1;
end
end
end
end
end
end
disp([Blobs1, Blobs2, Blobs3, Blobs4]);
I tried to loop on all the blobs contained in the image and then based on the Y centroid coordinate I tried to count them if inside of the region (4 equal horizontal strips). How to get this to work? Once I get this done the next step will be plotting the centroids on the original image, using different indexes for different regions. I'd be relieved if you can help me with this. Thanks.