lucasb-eyer / pydensecrf

Python wrapper to Philipp Krähenbühl's dense (fully connected) CRFs with gaussian edge potentials.
MIT License
1.94k stars 413 forks source link

How to specify my customized pairwise term? #40

Closed zeakey closed 6 years ago

zeakey commented 7 years ago

Hi all, I've designed my own pixel to pixel similarity metric and I want to make it part of the pairwise term. How can I implement this?

Can someone give me some tips?

lucasb-eyer commented 7 years ago

You can add any arbitrary pairwise energy to the DenseCRF through the void addPairwiseEnergy(const c_MatrixXf &features, LabelCompatibility*, KernelType, NormalizationType) method, have a look at create_pairwise_gaussian(sdims, shape) and create_pairwise_bilateral(sdims, schan, img, chdim=-1) in utils.py for two examples of methods creating a pairwise term.

Please let me know if that works, and consider contributing an example if it does!

lucasb-eyer commented 6 years ago

Closing due to no further question/feedback.