Exercise 2 Question 1 Convolutions

Exercise 2 Question 1 Convolutions

by Adam Misik -
Number of replies: 4

Hi, 

for the question 1 in exercise 2, I am having troubles understanding the i and j iterations for the output image R creation.  Shouldn't we iterate from [-N, N] and [-M,M], respectively, so that we stay in the bounds of the padded image I ? 



In reply to Adam Misik

Re: Exercise 2 Question 1 Convolutions

by Kaicheng Yu -

Hi Adam,

Could you define what is 'in the bounds of the padded image I'? 


Kaicheng 

In reply to Kaicheng Yu

Re: Exercise 2 Question 1 Convolutions

by Adam Misik -

Well, to rephrase that, when you are doing a convolution on the padded image I with a N X M kernel, and the convolution center is a pixel with coordinates (x,y), you should be looping through the pixel region with -N to N and -M to M. I do not see why we loop from -N to N+1 and -M to M+1.

Thanks and Best regards,

Adam

In reply to Adam Misik

Re: Exercise 2 Question 1 Convolutions

by Michal Jan Tyszkiewicz -
So your question is about the +1, correct? The answer is that in Python `range(a, b)` includes `a` and excludes `b`. So `range(-M, M+1)` iterates over -M, -M+1, ..., 0, ..., M-1, M (as you would expect). Does that answer your question?