title: How to implement a conditional random field based energy function from images?
body: <p>I am trying to implement some segmentation tool for my images, and I am trying to use conditional random field (CRF) based method. For example, in <a href="https://www.google.co.uk/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0CCUQFjAA&amp;url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D4497207&amp;ei=LfWrU52eO8TBPIrHgIgO&amp;usg=AFQjCNHDO9nr4-TwsYhRmn1eCwh3RAamvw&amp;sig2=KHaSgS2eqvYHr2e3g50a5Q&amp;bvm=bv.69837884,d.ZGU" rel="nofollow noreferrer">this paper</a>.</p>
  
  <p>The standard CRF energy function includes two parts, i.e., a unary potential and a pairwise potential</p>
  
  <p><img src="https://i.stack.imgur.com/tgNZ8.png" alt="Energy function"></p>
  
  <p>where L are the class labels and X are the observations (image pixels).</p>
  
  <p>I have got some training image with labels of the objects in the image. For example, I have got the ground truth segmentation of the objects in the image with labels.</p>
  
  <p>If I want to use texture of these objects as the feature, I am wondering how to implement and do the training of this energy function? For example, the unary term can be represented by</p>
  
  <p><img src="https://i.stack.imgur.com/7lBLg.png" alt="Unary term"></p>
  
  <p>where v_texture is a vectorised texture feature of each labelled object. </p>
  
  <p>My question is how to implement this log probability function? Using histogram? Thanks. A.</p>