dthuerck / mapmap_cpu

A high-performance general-purpose MRF MAP solver, heavily exploiting SIMD instructions.
BSD 3-Clause "New" or "Revised" License
103 stars 51 forks source link

Theoretical Questions about Unary and Pairwise Costs #41

Closed knsjoon closed 11 months ago

knsjoon commented 11 months ago

Hello, Daniel. I have got to know about mapmap_cpu from two mesh-texturing papers: specifically, MVSTexturing (https://github.com/nmoehrle/mvs-texturing) and Seamless Texturing (https://github.com/fdp0525/SeamlessTex). The usage of "mapmap_cpu" is to select the most optimal image to texture each and every possible faces of a mesh through MRF processes. I am still learning about MRF so I am here to ask if you can help me guide my thought processes and correct myself.

I get the intuitions behind setting unaries costs. Let us assume that the criterion to select the most optimal image for texturing for each face, is its clarity (<--> blurry). Then for a unary cost table, set a low cost for this pair of face and image in order to lead the selection of an image with low cost (clearest) for that specific face. At the same time, set a high value to a blurry image or even infinite for an image onto which this face is not projected.

For the pairwise costs, I see that many papers for texturing use "potts" or "orgPotts" model and I understood it being a method that penalize when two faces, that are neighboring, are labeled differently (for the texturing context, it would be, texturing two neighboring faces with different images, causing undesired seams).

So this is so far all background infos. I am wondering if my intuition is correct. Using a method like superpixels (https://www.epfl.ch/labs/ivrl/research/slic-superpixels/) that are "segmentation" methods, I set a low pairwise costs (I think "high" and "low" might be a bit ambiguous. For me, setting low costs mean, I want this choice to be eventually selected by the MRF optimization processes) for two neighboring faces ONLY when they land on same segmented areas for a certain image. Unlike Potts model that sets a constant penality for any neighboring faces that are projected onto a same image, I only penalize them by setting low pairwise costs when 1) two faces are neighboring 2) they are projected onto the same image 3) they land on the same segmented regions. So Criterion #3 is an additional consideration.

The reason behind this setup is to enforce assignments of a same image to faces that belong to the same group of segmented region I do not want to penalize if other neighboring faces belong to different segmented region.

I am self-teaching myself right now so I would appreciate any possible inputs from anyone! Thank you!

dthuerck commented 11 months ago

Hi,

yes, your intuition is correct! Essentially, for all the states you prefer, you'll set lower unary costs according to the specifics of your application. A good "example problem" to get you started (though a dated one) is the stereo problem, e.g. on the Middlebury benchmark: https://vision.middlebury.edu/stereo/

Here's an example of different (unary) cost functions, visualized: https://www.researchgate.net/figure/Comparison-of-different-matching-cost-functions-for-four-Middlebury-stereo-pairs_fig2_235417946

As you say, Potts model prefers the same labels for neighbouring nodes. If you have multiple labels that have geometric meaning, sometimes the truncated linear term p(x_1, x_2) = min(c, abs(x_1 - x_2)) is also a good choice.