Matlab,如何在特定的像素位置上应用medfilt2函数 [英] Matlab, how to apply medfilt2 function on specific pixel locations

查看:877
本文介绍了Matlab,如何在特定的像素位置上应用medfilt2函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想将medfilt2函数应用于特定像素位置而不是整个图像,是否有办法?可以使用称为IMask的二进制图像来表示像素位置。

Is there a way if I want to apply medfilt2 function to the specific pixel locations rather than the whole image? The pixel locations can be represented using a binary image called IMask.

推荐答案

懒惰的方法是在整个图像上应用 medfilt2 然后复制特定位置。例如,

The lazy method is to just apply medfilt2 on the whole image and then copy the specific locations. E.g.

A = magic(10); % sample matrix
IMask = logical(randi([0 1],10)); % sample locations

B = medfilt2(A);
A(IMask) = B(IMask);

不是很优雅,但除非您的矩阵很大且,否则它将完成工作IMask 大多是假的。

Not very elegant, but will do the job unless your matrix is gigantic and IMask is mostly false.

这篇关于Matlab,如何在特定的像素位置上应用medfilt2函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆