我需要使用@rayryeng在Matlab Wrapper for Graph Cuts中建议的Shai Bagon的this post从胸部X光图像中提取出一些不需要的物体。
我已经通过Boykov阅读了这篇论文,并了解了Graph Cuts的工作原理。我还下载了Shai Bagon的Matlab Warpper for Graph Cuts并编译了所需的mex文件。为了开始,我下载了简单的example图像分割。但是,我对如何使用
感到困惑[gch ...] = GraphCut(mode, ...);
用于分割灰度2D图像中不需要的对象。
任何帮助都会一如既往地受到赞赏。感谢。
答案 0 :(得分:4)
非常基础:
img = imread('http:%//i.stack.imgur.com/nntda.png'); %// read the image
img = img(:,:,1); %// use only one channel as it is a gray scale image
观察到物体大多比110亮,而其余肺部比这个值更暗,你可以定义每像素数据项:
Dc(:,:,1) = img > 110; %// cost of 1-st label (bg): penalize pixels brighter than 110
Dc(:,:,2) = img < 110; %// cost of 2-nd label (fg): penalize pixels darker than 110
lambda = 11; %// relative weight of smoothness cost vs. data cost
Sc = [0 1; 1 0]; %// give 0 cost for bg-bg or fg-fg transitions, and 1 cost for fg-bg transitions
使用GraphCut
包装器执行优化:
gch = GraphCut( 'open', Dc, lambda * Sc ); %// define the graph
[gch L] = GraphCut('expand', gch ); %//optimize and get the labeling L
gch=GraphCut('close',gch); %// clean up the mess
我会留给你找出改进这种方法的更多令人兴奋的方法......