how to assign the same labels to the segment between two consecutive markers?

1 view (last 30 days)
The aim of this is to assign the same label(bwlabel)to each segment(connected or not) located between two different markers in the image below :
can any one help me please!
help is much appreciated
thank you

Answers (2)

Walter Roberson
Walter Roberson on 27 Jan 2014
It sounds like you want to divide the area up into rectangular ROIs (region of interest), and assign the same number to all non-zero points in the ROI. If you want to do it fully automatically you are going to need to give rules about which pair of markers to select, as most of the obvious possibilities in the above figure would result in overlapping ROIs.
Once you have determined the bottom left and top right coordinates of an ROI rectangle, you can use
LabelMatrix = uint8(BWMatrix); %supposing the BWMatrix is logical resulting from thresholding or the like
LabelMatrix(bottomrow:toprow, leftcolumn:rightcolumn) = LabelMatrix(bottomrow:toprow, leftcolumn:rightcolumn) * CurrentLabel;

Image Analyst
Image Analyst on 27 Jan 2014
I think we talked about this before. You just erase the binary image at the location of your markers, then you call bwlabel(). This will do it.
% Marker rows are in the "rows" array.
% Marker columns are in the "columns" array.
for k = 1 : length(rows)
row = rows(k); % "y" value.
column = columns(k); % "x" value.
binaryImage(row, column) = false;
end
[labeledImage, numberOfSegments] = bwlabel(binaryImage);
  2 Comments
mika
mika on 29 Jan 2014
yes sir but the problem is that the segment between two markers is not connected for this we will find different labels between two markers
Any idea to recover that. thank you
Image Analyst
Image Analyst on 29 Jan 2014
They look connected by a solid blue line to me, except for a few small blobs where there's only one marker on it. Magnify and point out a blue structure where there is no connection between the markers on it. If there is no connection, then they are different blobs.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!