Kernel Matrix apply convolution

13 ビュー (過去 30 日間)
Patrick Carey
Patrick Carey 2015 年 4 月 10 日
コメント済み: Tim Harrell 2021 年 9 月 17 日
I believe I am close to the correct answer for this problem. The question basically is to apply convolution to a numeric matrix A and the kernel matrix. Conditions are the kernel matrix must be normalised before it can be used, dividing each element of the kernel by the sum of all the elements of the kernel (I've done that properly already I think). Need to calculate the margin that needs to be left at the beginning and end of each for loop(which I believe is 3), ensuring that the kernel martix passes over every element of A without going out of bounds. Here is my script so far, as I said before I think I'm close:
function [ B ] = kernelSmooth( A, kernel )
B=zeros(7,7);
nkernel = kernel./(sum(sum(kernal)));
for row = 1:size(A,1)-3
for col = 1:kernel-3
tmpMat= B(row-3:row+3,col-3:col+3) .* nkernel;
B(row,column) = sum(sum(tmpMat,3),1);
end
end
Help is appreciated, i have already spent a fair bit of time on this question
  2 件のコメント
Patrick Carey
Patrick Carey 2015 年 4 月 10 日
Also none of these functions are allowed: conv, conv2, convmtx, convn, deconv, filter, xcorr
Tim Harrell
Tim Harrell 2021 年 9 月 17 日
sum(sum(kernal.......
spelling ?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by