如何在二进制图像中分离由黑色界定的白色区域

时间:2016-05-16 12:09:26

标签: matlab image-segmentation

我正在MATLAB中进行肺癌检测。我想分割肺部CT扫描的二进制图像以获取感兴趣的区域。

在图片中,您可以看到黑色区域内的白色区域。黑色物体表示肺部,黑色物体内部的白色区域表示癌症影响肺部。我想从图像中获取白色区域。我想把输出只作为黑色背景中的那个白色区域。我怎样才能做到这一点?

input image

2 个答案:

答案 0 :(得分:1)

这样的事情怎么样:

% Read in image and convert to BW
BW = im2bw(imread('http://i.stack.imgur.com/pxpOz.jpg')); 

% Invert so that the lung appears white white
BW = ~BW; 

% Create a structuring element. Tune the '2' depending on the size of the gap
se = strel('disk',2); 

% Perform mophological closing
closeBW = imclose(BW,se); 

% Fill the holes
lungBW = imfill(closeBW,'holes'); 

% subtract the lung image from the closed image
cancerBW = (lungBW - closeBW); 

% Display the results
figure; imshow(cancerBW);

Click here for the output

答案 1 :(得分:0)

你没有给出代码,所以我也在没有代码的情况下回答。

你可以

  • 使用morpholocical关闭操作来摆脱将白色区域连接到周围
  • 的开放通道
  • 然后在每个黑色区域寻找白洞(例如,仅对黑色的(蒙面)区域进行斑点分析/阈值操作)

或者,你可以

  • 寻找轮廓的凸性缺陷,例如描述here(这是一个python版本,但类似的函数应该在matlab中出现)