Reputation: 365
Assume that I have greyscale image I that have 300 x 300
and I have matrix matrix M 3 x 3
after the convolution
Ans = conv2(I,M);
ans will be matrix 304 x 304 => convolute will extend the matrix
If I want the answer to be a matrix like I Can I force it like
Ans = Ans(1+2:304-2;1+2:304-2);
Upvotes: 1
Views: 715
Reputation: 865
You can use conv2(Image, Kernel, 'same')
:
>> load clown % X = image of a clown
>> size(X)
ans =
200 320
>> I = ones(10, 10);
>> size(conv2(X, I))
ans =
209 329
>> size(conv2(X,I,'same'))
ans =
200 320
Upvotes: 0