필터 지우기
필터 지우기

Correlation between 1 number and set of numbers

조회 수: 1 (최근 30일)
Emily Pendleton
Emily Pendleton 2019년 12월 13일
답변: Image Analyst 2019년 12월 13일
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)

답변 (1개)

Image Analyst
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.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by