Pairwise term for Graphcut

Very fast, vectorized code for calculating the pairwise term for algorithms like Graph cuts.
Updated 8 Oct 2012

View License

This code is inspired by Steve's post on Neighborhood indexing:

Four-connected neighborhood implementing the color difference between adjacent pixels in RGB space as a way to encode to similarity.

1/(norm(I1(:)- I2(:))+1)


timeit(@() pairwise_term(imread('peppers.png')))

ans =


Please obtain the timeit function from here:

Cite As

Bharath Ramesh (2024). Pairwise term for Graphcut (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes