<p>To cut a long story short: using the "conventional" graph cut formulation, the pair-wise term is used to encourage smoothness. It can be tuned based on local gradients to be weaker across image boundary, but as you correctly noted, it is always non-negative, thus, it never encourages changing of label (unless strong evidence exists in the per-pixel term).</p>

<p>The requirement for non-negative pair-wise terms is called "sub-modularity" and only for sub-modular energies there exist a polynomial time solution (exact for the 2-labels case, good approximation for multiple labels).<br>
You can read more about the "sub-modularity" in this context at <a href="http://www.cs.cornell.edu/~rdz/papers/kz-pami04.pdf" rel="nofollow noreferrer"><em>Kolmogorov and Zabih</em>, <strong>What Energy Functions can be Minimized via Graph Cuts?</strong>, PAMI 2004</a>.</p>

<p>However, you can define non sub-modular weights for the pairwise terms across image boundaries. You will no longer be able to use the "conventional" GCMex implementation, however, there are some nice approximation algorithms that can give not reasonable results even in the shaky realm of non sub-modular energies.<br>
The first approximation to explore, for the two-labels case, is <a href="https://github.com/shaibagon/large_scale_cc/tree/master/QPBO-v1.3.src" rel="nofollow noreferrer">QPBO</a>, described at <a href="http://pub.ist.ac.at/~vnk/papers/KR-PAMI07.pdf" rel="nofollow noreferrer"><em>Kolmogorov and Rother</em>, <strong>Minimizing non-submodular functions with graph cuts - a review</strong>, PAMI 2007</a>.<br>
The next step is a multi-label, <a href="https://github.com/shaibagon/discrete_multiscale" rel="nofollow noreferrer">multi-scale approximation</a>, described at <a href="http://arxiv.org/abs/1204.4867" rel="nofollow noreferrer"><em>Bagon and Galun</em>, <strong>A Multiscale Framework for Challenging Discrete Optimization</strong>, NIPS 2012</a>.</p>

<p>Last but not least, if you only have pair-wise interactions (positive <strong>and</strong> negative) and no clear per-pixel terms, you might want to consider segmentation using <a href="https://stackoverflow.com/a/19510366/1714410">Correlation Clustering</a> functional.</p>
Encourage object boundaries at edges in Graph cut segmentation
<p>Up to now I have been segmenting some grayscale images using either Otsu's method or K-means. I noticed however that the segmentation cannot be "perfect" only based on the intensity. At least one would have to consider local gradients in the image.</p>

<p>I then did some research and came across the graph cut segmentation algorithm. I thought this algorithm would be beneficial since</p>

<ol>
<li>The relationship between neighboring pixels is considered</li>
<li>I could incorporate prior knowledge if I know of pixels that belong to a certain class beforehand.</li>
</ol>

<p>I now have been doing some tests using <a href="https://github.com/shaibagon/GCMex" rel="nofollow">Shai's MATLAB Graph Cut wrapper</a> and noticed that Graph Cut does not seem as beneficial as I thought. Based on the gradient I can reduce the penalty for a class border, but I can't <em>encourage</em> the algorithm to draw boundaries at edges - if a boundary is not present in the initialization via K-Means/Otsus (to create Dc) the algorithm won't draw one even though there might be a strong local edge. I think this is due to the fact that costs need to be positive.
Hence it seems as that Graph-Cut here only helps to smoothen boundaries but it won't help me to introduce "new ones".</p>

<p>Long story short: Does my story above sound plausible to you, i.e. do my conclusions make sense? Or, is there a way to use edges to create boundaries?</p>

<p>Thanks!</p>

<p>PS. Sorry, I can't show a real image I am talking about here :(</p>