title: How to find correlation of an image?
body: <p>There is an image <code>A</code> of fixed size 256*256*3 (RGB). The mathematical formula for covariance between two adjacent pixels values <code>x,y</code> in an image is popularly known to be:</p>
  
  <pre><code>cov(x,y) = 1/n summation from i = 1 to n of [E(x_i-E(x))(y_i-E(y))]
  
  r_xy = cov(x,y) / (sqrt(D(x)*D(y)))
  
  D(x) = 1/n summation  from i = 1 to n of square[(x_i - E(x))]
  
  E(x) = 1/n summation from i = 1 to n of (x_i)
  </code></pre>
  
  <p>where <code>r_xy</code> is the correlation coefficients between two horizontally, vertically, and diagonally adjacent pixels of these two images.</p>
  
  <p><strong>Q1:</strong> How to do the above computation in MATLAB?</p>
  
  <p><strong>Q2:</strong> How to randomly select say 5000 pairs of two horizontally adjacent pixels from the images and then plot the distribution of these two horizontally adjacent pixels?</p>