(1) Let , ;
(2) Calculate aggregated weighting ;
(3) For each patch pair and
(4)  Calculate ;
(5)  if ( ) ;
(6)  else ;
(7)   ;
(8) End for
(9) Output ;
Algorithm 2: Transposed PPF.