Analysis of atomic density distributions in optical lattices using an optical mask