Aru*_*iRC 11 matlab image-processing computer-vision matlab-cvst
使用detectMSERFeatures从Matlab中的图像中找到最大稳定的极值区域(MSER).
是否有任何补丁或方法可以从Matlab 获取分层MSER组件树?
当Matlab计算区域时,无论如何都会生成此树 - 它只返回每个区域树中最"稳定"的组件.由于这个树已经存在,我正在寻找从Matlab库中向用户代码公开的方法,这样可以隐藏这个部分,并且只提供最终的"最大稳定"区域.
任何事情都是可以接受的 - 修改Matlab内置代码,补丁,黑客等等.(我意识到OpenCV有这样的补丁,但是我试图避免移植到OpenCV,因为大多数其他程序都是用Matlab编写的).
编辑:(从原来的分层MSER论文)

Detected MSERs(左), MSER Tree(右)
小智 2
“分层 MSER 组件树”是一个令人困惑的短语,因为 (1) 组件树已经是分层的 (2) 如果您想要整个树,那么您不仅仅需要最大稳定极值区域 (MSER),而是您想要所有极值区域,并且 (3) 极值区域和组件在这种情况下是相同的。
假设您想要极值区域树。正如评论中所指出的,您无法准确地获得 MATLAB 使用的函数,因为它detectMSERFeatures.m调用了我们没有源代码的 mex 函数(不过,根据其输入和名称,它可能与 openCV MSER 函数非常相似) 。但您仍然可以计算自己的极值区域树。基本上,此代码的作用是在不同阈值级别的图像中查找连接的组件。这些 CC 是极值区域。代码中最棘手的部分是记录父关系。这应该可以帮助您开始:
% input image, included with MATLAB
x = imread('rice.png');
pixelList = {};
parents = [];
oldERsLabeled = zeros(size(x));
oldPixelList = {};
regionLabelOffset = 0;
for i = 255:-10:1 % the stride here is important, smaller will be slower and give more regions
newERs = bwlabel(x > i);
newERsLabeled = zeros(size(newERs));
newERsLabeled(newERs > 0) = newERs(newERs > 0) + regionLabelOffset;
regionLabelOffset = max(newERsLabeled(:));
% update the list of regions
props = regionprops(newERs, 'pixelList');
newPixelList = {props(:).PixelList};
pixelList = [pixelList newPixelList];
% figure out parents
newParents = cellfun(@(c)(newERsLabeled( sub2ind(size(x), c(1,2), c(1,1)))), oldPixelList);
parents = [parents; newParents'];
oldPixelList = newPixelList;
oldERsLabeled = newERsLabeled;
end
parents(end+1 : length(pixelList)) = -1; % top level regions have no parents
pixelListInt = cellfun(@int32, pixelList, 'UniformOutput', false);
regions = MSERRegions(pixelListInt');
% plot the first 300 regions
figure
imshow(x)
hold on
plot(regions(1:300), 'showEllipses', false, 'showPixelList', true);
% show all parents of a region ("close all" command might be useful after)
curRegion = 102;
while curRegion ~= -1
figure
imshow(x)
hold on
plot(regions(curRegion), 'showEllipses', false, 'showPixelList', true);
curRegion = parents(curRegion);
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2246 次 |
| 最近记录: |