title: MATLAB: Entropy associated to the intensity-gradient joint histogram
body: <p>One of the most widely used homogeneity measurements is the Shannon entropy:
  <img src="https://i.stack.imgur.com/lA1az.png" alt="enter image description here"></p>
  
  <p>where p is the normalized histogram of an image of L grey levels.</p>
  
  <p>We can measure such entropy by using not only image intensities but also image local gradients, since homogeneous images not only exhibit well ordered intensities but also well clustered very low gradient values in homogeneous regions ( J.V. Manjon et al, “A Nonparametric MRI Inhomogeneity Correction Method”, Medical Image Analysis, 2007).</p>
  
  <p>Let Y be an image with M pixels and L1 grey levels, and let G be the associated image corresponding to the magnitude of the local gradient with L2 grey levels. The intensity gradient joint histogram is defined as:
  <img src="https://i.stack.imgur.com/2HQLu.png" alt="enter image description here"></p>
  
  <p>where δ is the Kronecker delta function. 
  So the normalized intensity-gradient joint histogram:
  <img src="https://i.stack.imgur.com/2Bqjs.png" alt="enter image description here"></p>
  
  <p>Therefore the entropy associated to the intensity-gradient joint histogram
  is:
  <img src="https://i.stack.imgur.com/dWXnd.png" alt="enter image description here"></p>
  
  <p>I need to calculate the above entropy for biomedical image data: <a href="https://i.stack.imgur.com/I4hf4.png" rel="nofollow noreferrer">http://i.stack.imgur.com/I4hf4.png</a>. I found this discussion useful: <a href="https://stackoverflow.com/questions/23691398/mutual-information-of-two-images-matlab">Mutual information and joint entropy of two images - MATLAB</a>, but I don't know if the joint histogram and the joint entropy calculated (by @rayryeng) in this discussion are the same as what I need, and if not, how I could calculate this entropy using Matlab? Any help is as always appreciated.</p>