add test cpp
add mean-difference and pixel energy function