I have a double matrix with dimensions 500x500. The matrix has numerical and NaN values. So far I have been able to do the following. I loop through each matrix element. At the particular element, I extract the pixel and its neighbors. Neighbors consist of 8 surrounding elements or less if the element is on an edge or corner. Then, I exclude any NaN values because I don't want them included in the following calculations.
Here is where I am having trouble. Overall, I want to be able to show how well do these surrounding pixels "describe" the pixel of interest. To do so, I want to find the average correlation coefficient between the element of interest and its surroudning neighbors. That is, find the correlation coefficient between the element and each of its neighbors, then find that average. Then I want to replace the element of interest with this value. If the element of interest is NaN, I want to keep it NaN. I will end up with a 500x500 matrix with NaN and values that correspond to the average correlation coefficient between that element and its neighbors.
I am having trouble with matlabs correlation coefficient command for finding this number between two values. It keeps giving me a value of 1 for two numbers that are not similar. Right now, I am using a = corrcoef(A,B) to find the corr. coeff. for the element of interest and each surrounding neighbor. Is there something I am missing? Is there another statistical value other than corr. coeff. that I could potentially use in place of this?
Thank you SO much for any help at all!