I do know that we must pad an image while using a filter. But what I am suggesting is that is it really necessary? Can't we just calculate at run time if the current cell/pixel is an edge cell/pixel and then use the padding value directly over there. It might add an overhead to the function but so does the entire padding function.
Only reason I think the padding function should be used is if the padded version of original image is going to be used in many different function which will overtake the overhead of dynamically calculating the edge cell/pixel values(which might never occur). Am I wrong?