查找标签图的多边形边界
find polygon boundaries for a labelmap
我有一个描述图像的标签映射矩阵。如图所示,在Matlab中可视化为
imshow(im,[])
如何提取描述每个标签区域的多边形边界?对于所有标签,我会有一组多边形边界。提取所有这些多边形边界的最有效方法是什么?
您只需使用 imcontour
或 bwboundaries
即可。这是一个例子:
% Get the values in your image
val = unique(im);
% Pre-allocate output
C = cell(numel(val),1);
% Here we go
for i = 1:numel(val)
C{i} = bwboundaries(im==val(i));
end
输出 C
将是一个包含轮廓的单元格。
NB: your original image looks like a raw conversion to a few levels of
gray. To reduce noise at the boundaries, you may want to consider
applying a median filter with imfilter
and filter
.
我有一个描述图像的标签映射矩阵。如图所示,在Matlab中可视化为
imshow(im,[])
如何提取描述每个标签区域的多边形边界?对于所有标签,我会有一组多边形边界。提取所有这些多边形边界的最有效方法是什么?
您只需使用 imcontour
或 bwboundaries
即可。这是一个例子:
% Get the values in your image
val = unique(im);
% Pre-allocate output
C = cell(numel(val),1);
% Here we go
for i = 1:numel(val)
C{i} = bwboundaries(im==val(i));
end
输出 C
将是一个包含轮廓的单元格。
NB: your original image looks like a raw conversion to a few levels of gray. To reduce noise at the boundaries, you may want to consider applying a median filter with
imfilter
andfilter
.