SelectComponents
Matlab在mathematica中有替代功能吗?
这个 wolfram mathematica 代码如何转换为它的 matlab 等价物。
(* Connected component selection based on some supposed sizes. *)
ccs = SelectComponents[wsthick, "Count", 1000 < # < 3000 || 6000 < # < 10000 &]
SelectComponents
Matlab在mathematica中有替代功能吗?
这个 wolfram mathematica 代码如何转换为它的 matlab 等价物。
(* Connected component selection based on some supposed sizes. *)
ccs = SelectComponents[wsthick, "Count", 1000 < # < 3000 || 6000 < # < 10000 &]
在 Matlab 中,您可以regionprops
用于计算图像中标记区域的不同属性。
对于你的问题,我会尝试
lb = bwlabel( wsthick, 4 ); % use 4-connect regions in bw image
s = regionprops( lb, 'Area', 'PixelIdxList' ); % extract area of regions - number of pixels they cover
count = [s(:).Area] ; % a vector with count for each region
sel = ( ( count > 1000 & count < 3000 ) | ( count > 6000 & count < 10000 );
ccs = false( size( wsthick ) );
ccs( vertcat( s(sel).PixelIdxList ) ) = true;
可能不像 Mathematica 那样优雅,但工作方式相同。