how to locate blobs upper middle and lower middle points and plot it

2 views (last 30 days)
i am trying to locate points like it shows in the figure 4 below were the centroid i have marked as shown in figure 2 from the binary image now i have to mark upper lower and left and right boundry point as in fig 4 ..any one help me
I have marked the centroid of the blob using
s = regionprops(binaryImage, 'centroid');
centroids = cat(1, s.Centroid);
imshow(binaryImage);
hold(imgca,'on');
plot(imgca,centroids(:,1), centroids(:,2), ...
'r*','MarkerSize', 10, 'LineWidth', 3);

Accepted Answer

Image Analyst
Image Analyst on 9 Dec 2013
  1 Comment
Anandakumar Selvaraj
Anandakumar Selvaraj on 8 Jan 2014
Edited: Anandakumar Selvaraj on 8 Jan 2014
The answer to my question is already answered by Image Analyst in Ths Post
centroidColumn = int32(centroid(1)); % "X" value
centroidRow = int32(centroid(2)); "Y" value.
Then extract a row or column and use find to find the first and last element that's set:
middleColumn = binaryImage(:, centroidColumn);
topRowY = find(middleColumn, 1, 'first'); % Find top.
bottomRowY = find(middleColumn, 1, 'last'); % Find bottom.
middleRow = binaryImage(centroidRow, :);
leftColumnX = find(middleRow, 1, 'first'); % Find left.
rightColumnX= find(middleRow, 1, 'last'); % Find right.
so i am accepting his above answer

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!