Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

The image gradient is the rate of change over any given pixel of an image, either in the horizontal or vertical direction. An image can be thought of as a large matrix of values [0, 255]. A common horizontal matrix for taking an image gradient is [1, 0, -1], or the value to the left of our pixel minus the value to the right of our pixel.

I understand this conceptually, but in practice I'm not sure how to apply it to the edges of an image (eg the value to the left or the right of the pixel doesn't exist).

http://en.wikipedia.org/wiki/Image_gradient#Math

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Check out the documentation for the matlab function 'imfilter'. The first box on that page has the title 'Boundary Options'. It list four options, for example: 'replicate' Input array values outside the bounds of the array are assumed to equal the nearest array border value.

This is a standard problem when filtering an image (and you are approximating the gradient with a filter), and there are many ways to deal with it that are more or less equally good.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.