Zda*_*daR 8 graph image-processing image-segmentation max-flow
我试图从研究论文中描述的给定图像中提取头发,使用能量最小化的概念,能量函数依赖于先验概率和YCrCb颜色似然直方图.能量函数定义为:
(x)= data(x)+smooth(x).
Run Code Online (Sandbox Code Playgroud)
data(x)= - Σ(log(I(x)| x)+ logsel(x)) [先验概率模型]
smooth(x)=Σ(x≠x)exp( - ||(x) - (x)|| ^ 2 /) [先前的YcrCb颜色模型]
我很困惑如何标记给定的图形(图像的像素被视为图形的节点).我尝试使用以下方法标记图形,但结果不符合预期:
def get_Edata(prob_dist, ycrcb_dist, img_y, img_x, pix):
e_data = 0
Y, Cr, Cb = pix
if ycrcb_dist[int(Y/4)][int(Cr/4)][int(Cb/4)] > 0 and prob_dist[img_y][img_x]>0:
e_data = -1*(math.log(ycrcb_dist[int(Y/4)][int(Cr/4)][int(Cb/4)], 10) + math.log(prob_dist[img_y][img_x], 10))
return e_data
def get_ESmooth(normalization_constant, pix_1, pix_2):
return math.exp(-(math.ceil(pix_1[0] - pix_2[0])**2)/normalization_constant)
Run Code Online (Sandbox Code Playgroud)
虽然在图表中的节点之间添加权重,但我使用:
#adding the edges between neighbouring pixels.
img_graph.add_edge(central_node, neighbour_nodes, eSmooth, 0)
#adding the edges from source to node and from node to sink.
img_graph.add_tedge(central_node, weight_source, max_val_weight-source)
Run Code Online (Sandbox Code Playgroud)
我想问题是max_val_weight-source因为将值更改为某个较低的整数会给我相对较好的结果,但这不是正确的方法.
将eSmooth的值更改为0也不会影响输出?
如果有人能够对这种情况有所了解,我将非常感激.
| 归档时间: |
|
| 查看次数: |
313 次 |
| 最近记录: |