Real-Time Video Bilayer Segmentation–Theory–Part 3 Color Likelihood Propagation
Side Note: First Draft on Apr 1 2011.
This article is a follow up of the Part 2 Producing the Trimap.
4. Color Likelihood Propagation
The Trimap based on Iprob divides the video frame into foreground (F), background (B) and unknown (U) regions. MRF can be applied to classify the pixels in U.
In the MRF energy equation, all other terms can be calculated based on previous computation except for L(pi|F) and L(pi|B), which are the color likelihood of some reliable feature points in the video frame.
The color likelihood propagation technique first will identify reliable pixels from a frame based on feature selection and motion between two adjacent frames (itself and next frame). Once these pixels are identified, their color likelihood are calculated.
The calculation is based on foreground and background distribution, meaning the segmentation result is already known. Therefore we use previous segmentaed frame to estimate the color likelihood of current frame. In other words, a pixel p’s likelihood in current frame is assumed to be the same as the likelihood of its corresponding pixel q (based on optical flow to find the correspondence) in the previous frame.
The calculation is as below,
Let’s use foreground as an example. First, the mean color Fi and covariance of the foreground color distribution is calculated as above. where Wi is a regularization constant. wq is spatial Gaussian coefficient with σ = 8. Cq is the color vector for a pixel q. Ni is the known foreground colors within q’s neighborhood.
Then the foreground color likelihood of q is computed as,
This L(qi|F) is assumed to be the same as L(pi|F) in the current frame, which is what we’re looking for.
Based on background color distribution, L(pi|B) can also be calculated.
But how to select reliable feature and do optical flow in the first place?
Good Features to Track is a research paper talking about a technique of selecting reliable features to track in feature-based vision system. It is used to select good features.
Lucas-Kanade Optical Flow is a technique to compute motion between two frames.
These two techniques are not covered here, and there’s tons of material online. Fortunately, OpenCV library has a good implementation of these two techniques. And one can apply them by making very simple function calls.
This color likelihood is different from the part 1 color likelihood in the sense it based on local color distribution, as it’s computed against a pixel’s neighborhood Ni, where the color likelihood of part 1 is based on color histogram, which indicates the global distribution of colors.
5. To be Continued on Implementation
With this final piece, MRF can be applied to solve the energy equation. This completes the theory for Real-Time Bilayer Segmentation. Part 4 will start with implementation, it’s done with Matlab, OpenCV C++ libraries, and MRF C++ libraries.
Please download the implementation source code here.
2 comments on “Real-Time Video Bilayer Segmentation–Theory–Part 3 Color Likelihood Propagation”
Leave a Reply Cancel reply
40% Discount on My Book — Android NDK Cookbook
Android NDK Cookbook ebook 40% discount with promotion code MREANC40 at Packt Publishing The promotion code is valid until 15th June.Categories
- Android Apps (18)
- Android Audio Editor (1)
- TS 2 (3)
- Video Converter Android (8)
- Video2Gif (1)
- Android Tutorial (26)
- Android Dev Tools (1)
- API illustrated (8)
- Multimedia API (3)
- ffmpeg on Android (4)
- NDK (6)
- UI (5)
- Animation (1)
- Code Snippet (2)
- Coding Beyond Technique (18)
- a word, a world (4)
- Bug Rectified (4)
- Programming Habit (1)
- Software as a Career (1)
- Software as User Experience (1)
- Compilers and Related (2)
- ELF (2)
- Computer Languages (31)
- C/C++ (13)
- Java (9)
- JavaScript (2)
- PHP (1)
- Python (8)
- Data Structure & Algorithms (29)
- Bits (1)
- Data Structure (5)
- Integers (10)
- BigInteger (1)
- Prime (4)
- Search (3)
- Sorting (5)
- Strings (5)
- Database (1)
- SQLite (1)
- Digital Signal Processing (33)
- Distributed Systems (17)
- Apache Cassandra (6)
- Apache Hadoop (8)
- Apache Avro (3)
- Apache Nutch (3)
- Apache Solr (1)
- Linux Study Notes (40)
- crontab (1)
- Linux Kernel Programming (8)
- Linux Programming (12)
- IPC (2)
- Linux Network Programming (5)
- Linux Signals (2)
- Linux Shell Scripting (1)
- ssh (3)
- Machinery (30)
- misc (1)
- My Ideas (1)
- My Project (3)
- Mobile Caching (1)
- Selective Decoding (2)
- My Publication (1)
- My Readings (1)
- Networking (15)
- Program for Performance (8)
- Uncategorized (1)
- Virtual Machine (2)
- Web Dev (8)
- web components (3)
- Android Apps (18)
Recent Comments
Archives
- May 2013 (1)
- April 2013 (1)
- March 2013 (4)
- December 2012 (2)
- November 2012 (6)
- October 2012 (6)
- September 2012 (3)
- August 2012 (13)
- July 2012 (15)
- June 2012 (3)
- May 2012 (8)
- April 2012 (4)
- March 2012 (13)
- February 2012 (19)
- January 2012 (9)
- December 2011 (11)
- November 2011 (12)
- October 2011 (4)
- September 2011 (12)
- August 2011 (16)
- July 2011 (15)
- June 2011 (6)
- May 2011 (10)
- April 2011 (13)
- March 2011 (20)
- February 2011 (4)
- November 2010 (2)
- May 2010 (1)
- April 2010 (1)
- February 2010 (1)





what I was looking for, thanks
I am building example.cpp on windows7 with VS2010. and the following are the error I get. What I am doing wrong? Please help me.
1>—— Build started: Project: MRF_TEST2, Configuration: Debug Win32 ——
1>Build started 23/02/2012 4:33:34 PM.
1>InitializeBuildStatus:
1> Touching “Debug\MRF_TEST2.unsuccessfulbuild”.
1>ClCompile:
1> All outputs are up-to-date.
1> MRF_TEST2.cpp
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: __thiscall BPS::BPS(int,int,int,class EnergyFunction *)” (??0BPS@@QAE@HHHPAVEnergyFunction@@@Z) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: __thiscall TRWS::TRWS(int,int,int,class EnergyFunction *)” (??0TRWS@@QAE@HHHPAVEnergyFunction@@@Z) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: __thiscall MaxProdBP::MaxProdBP(int,int,int,class EnergyFunction *)” (??0MaxProdBP@@QAE@HHHPAVEnergyFunction@@@Z) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: __thiscall Swap::Swap(int,int,int,class EnergyFunction *)” (??0Swap@@QAE@HHHPAVEnergyFunction@@@Z) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: void __thiscall MRF::optimize(int,float &)” (?optimize@MRF@@QAEXHAAM@Z) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: double __thiscall MRF::totalEnergy(void)” (?totalEnergy@MRF@@QAENXZ) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: void __thiscall MRF::initialize(void)” (?initialize@MRF@@QAEXXZ) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: __thiscall ICM::ICM(int,int,int,class EnergyFunction *)” (??0ICM@@QAE@HHHPAVEnergyFunction@@@Z) referenced in function _wmain
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: __thiscall GCoptimization::GCoptimization(int,int,int,class EnergyFunction *)” (??0GCoptimization@@QAE@HHHPAVEnergyFunction@@@Z) referenced in function “public: __thiscall Expansion::Expansion(int,int,int,class EnergyFunction *)” (??0Expansion@@QAE@HHHPAVEnergyFunction@@@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “public: virtual double __thiscall GCoptimization::dataEnergy(void)” (?dataEnergy@GCoptimization@@UAENXZ)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “public: virtual double __thiscall GCoptimization::smoothnessEnergy(void)” (?smoothnessEnergy@GCoptimization@@UAENXZ)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “public: virtual void __thiscall GCoptimization::setNeighbors(int,int,double)” (?setNeighbors@GCoptimization@@UAEXHHN@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall Expansion::optimizeAlg(int)” (?optimizeAlg@Expansion@@MAEXH@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “public: virtual void __thiscall GCoptimization::clearAnswer(void)” (?clearAnswer@GCoptimization@@UAEXXZ)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “public: virtual void __thiscall GCoptimization::setParameters(int,void *)” (?setParameters@GCoptimization@@UAEXHPAX@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “public: virtual char __thiscall MRF::checkEnergy(void)” (?checkEnergy@MRF@@UAEDXZ)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall GCoptimization::setData(double *)” (?setData@GCoptimization@@MAEXPAN@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall GCoptimization::setData(double (__cdecl*)(int,int))” (?setData@GCoptimization@@MAEXP6ANHH@Z@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall GCoptimization::setSmoothness(int,double,double)” (?setSmoothness@GCoptimization@@MAEXHNN@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall GCoptimization::setSmoothness(double (__cdecl*)(int,int,int,int))” (?setSmoothness@GCoptimization@@MAEXP6ANHHHH@Z@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall GCoptimization::setSmoothness(double *)” (?setSmoothness@GCoptimization@@MAEXPAN@Z)
1>MRF_TEST2.obj : error LNK2001: unresolved external symbol “protected: virtual void __thiscall GCoptimization::setCues(double *,double *)” (?setCues@GCoptimization@@MAEXPAN0@Z)
1>MRF_TEST2.obj : error LNK2019: unresolved external symbol “public: virtual __thiscall GCoptimization::~GCoptimization(void)” (??1GCoptimization@@UAE@XZ) referenced in function “public: virtual __thiscall Expansion::~Expansion(void)” (??1Expansion@@UAE@XZ)
1>D:\MRF_TEST2\Debug\MRF_TEST2.exe : fatal error LNK1120: 23 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.99
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========