(1)  Let , ;
(2)  For each patch pair and
(3)   if ( ) Calculate by (8);
(4)   else ;
(5)    , , aggregate the weighted images;
(6)  End for
(7)  Output ;
Algorithm 1: Image approximation by PPF.