سؤال

I have an image which matrix has some pixels with value NaN. For such certain pixel, I want to compare its 8-neighbourhood, and assign it a value based on that neighborhood.

I think for the neighbourhood we use nlfilter?

How can I do that in matlab?

Thanks.

هل كانت مفيدة؟

المحلول

You could decide by isnan, e.g.

M = nlfilter(M, [3,3], @neighFun);

function ret = neighFun(x)
    if isnan(x(2,2))
        ret = whatever;
    else
        ret = x(2,2);
    end
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top