9

我试图从研究论文中描述的给定图像中提取头发,使用能量最小化的概念,能量函数取决于先验概率和 YCrCb 颜色似然直方图。能量函数定义为:

(x)= data(x)+smooth(x).

data (x)=−∑(log(I(x)|x)+logsel (x)) [先验概率模型]

平滑 (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)

在图中我使用的节点之间添加权重时:

#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)

我想问题在于,max_val_weight-source因为将值更改为一些较低的整数会给我带来相对较好的结果,但这不是正确的做法。

将 eSmooth 的值更改为 0 也不会影响输出?

如果有人能对这种情况有所了解,我将不胜感激。

4

0 回答 0