Pairwise term for Graphcut
Version 1.0.0.0 (1.66 KB) by
Bharath Ramesh
Very fast, vectorized code for calculating the pairwise term for algorithms like Graph cuts.
This code is inspired by Steve's post on Neighborhood indexing:
http://blogs.mathworks.com/steve/2007/03/28/neighbor-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)
Example:
timeit(@() pairwise_term(imread('peppers.png')))
ans =
0.2037
Please obtain the timeit function from here:
Cite As
Bharath Ramesh (2026). Pairwise term for Graphcut (https://uk.mathworks.com/matlabcentral/fileexchange/38522-pairwise-term-for-graphcut), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2012a
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
- Image Processing and Computer Vision > Image Processing Toolbox > Image Filtering and Enhancement > Neighborhood and Block Processing >
Find more on Neighborhood and Block Processing in Help Center and MATLAB Answers
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
