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

2 次查看(过去 30 天)
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

回答(2 个)

Walter Roberson
Walter Roberson 2014-1-27
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 2014-1-27
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 个评论
mika
mika 2014-1-29
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 2014-1-29
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.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by