I tried to extract hair from a given image, as described in a research paper , using the concept of minimizing energy. The energy function depends on both probabilistic probability and YCrCb. The energy function is defined as:
πΈ(πx)= πΈdata(πx)+πΈsmooth(πx).
πΈdata (πx) = - Ξ£ (logπ (I (x) | πx) + logπsel (πx)) [Previous probabilistic model]
πΈ Smooth (πx) = Ξ£ Ξ΄ (πx β πx) exp (- || π (xπ) -π (xπ) || ^ 2 / Ξ³) [Prior YcrCb color model]
I am confused about how to designate this graph (image pixels are considered as nodes of the graph). I tried to mark the graph using the following approach, but the results are not as expected:
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)
And adding weight between nodes in the graph, I use:
#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)
I think the problem is with max_val_weight-source , because changing the value for some lower integer gives me relatively good results, but this is the wrong way to do this.
Also, changing the eSmooth value to 0 does not affect the output?
I would really appreciate it if someone could shed light on this context.