fn for computing histogram of iamge