【问题标题】:Finding the neighbourhood of certain pixels查找某些像素的邻域
【发布时间】:2013-04-21 05:01:52
【问题描述】:

我有一个图像,其中矩阵有一些像素值为NaN。对于这样的特定像素,我想比较它的8-neighbourhood,并根据该邻域为其分配一个值。

我认为对于我们使用nlfilter 的社区?

如何在matlab 中做到这一点?

谢谢。

【问题讨论】:

    标签: matlab nan neighbours


    【解决方案1】:

    您可以通过isnan 来决定,例如

    M = nlfilter(M, [3,3], @neighFun);
    
    function ret = neighFun(x)
        if isnan(x(2,2))
            ret = whatever;
        else
            ret = x(2,2);
        end
    end
    

    【讨论】:

    • @matheburg。感谢您的回复。函数名前面的@是什么意思?
    • @neighFun 是function handle。这意味着您将对 neighFun 的引用移交给 nlfilter。如果没有“@”,它将尝试调用 neighFun 并将返回值交给 nlfilter。
    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 2018-10-15
    • 1970-01-01
    • 2014-02-05
    • 2020-11-08
    • 2023-03-10
    • 2014-05-09
    相关资源
    最近更新 更多