如何在Matlab中将图像与内核/过滤器相乘

时间:2018-11-14 04:16:16

标签: matlab image-processing

enter image description here

如您在图像中所见,如何将A和B与步幅3x3相乘? 有人可以向我解释我该怎么做吗?一些代码示例将不胜感激

1 个答案:

答案 0 :(得分:2)

看起来您正在寻找的是

Result = repmat(A,2,2) .* B;

repmat沿每个维度重复矩阵A两次。您可以根据AB的大小来指定重复矩阵的次数,只要AB中适合整数倍即可:

reps = size(B) ./ size(A);
assert(all(mod(reps,1)==0))
Result = repmat(A,reps) .* B;