java code for stencil and histogram added