reduce output arguments (maskedImg)
Small Modifications

comments, variables
input argument number is 3, fixed