Correlation between 1 number and set of numbers
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have a 500x500 matrix of numbers and NaN values. I want to determine the average correlation coefficient between a pixel and its nearest 8 neighbors (3x3 grid) while omitting NaN values from the calculation. My output will then be a 500x500 matrix of correlation coefficients and NaN values. When calculating values on the edge of the matrix, I will use however many neighbors surround the pixel of interest in the 3x3 grid.
Any ideas on how to do this? I am aware of the corrcoef command, but I don't know how to make it work for the comparison of multiple numbers.
Thanks in advance.
MATLAB Version: 9.5.0.944444 (R2018b)
댓글 수: 0
답변 (1개)
Image Analyst
2019년 12월 13일
One way to do it is to use nlfilter(). I'm attaching a demo. Inside your custom function you'd take the local neighborhood and extract only the non-nan values with isnan(), then call corrcoeff() on those non-nan values only.
Attach your image in a .mat file, and your code if you can't figure out how to adapt it.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!