How do I treat the edges of an image?

조회 수: 2 (최근 30일)
Paul Johnson
Paul Johnson 2011년 5월 23일
Hi all,
I've got an image which I want to perform smoothing operations on. As my convolution is 5x5 it won't work properly when it borders the edge of the image. What can I do about this? Also, what buzz words could I search for that would help me understand this further?
Here's what I understand I could do: - nothing, let the convolution go off the edge of the image and get skewed results, or assign a value automatically - nothing, let the convolution go as close to the edge as the mask allows, without going off the edge, meaning a row of pixels around the edge of the page wouldn't be acted upon. - when the mask goes off the edge of the image, I could reflect the values from the other half that remains on the image. - when the mask goes off the edge of the image, I could wrap the values around from the opposite side of the image (not suitable for my application)
As I said, I don't really know what the names of each of these techniques are, so in addition to your advice, I could also do with help in naming these techniques so I can search for them more effectively.
Thanks so much, Paul

채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 23일
The approach you would take depends upon whether your image is intended to be periodic or not. If it is not, then you would usually logically pad with zeros, do the convolution, and then pare back to the initial size.
If it is intended to be periodic, then reflection can work in some cases, but runs the risk of being logically equivalent to "absolute value" in the sense that absolute value is a continuous function for the purposes of calculus and so mathematical reasoning about the result can be difficult.
Using values from the other edge is sometimes the most suitable for periodic functions.
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 5월 23일
I am not an image specialist, but it seems to me Yes.
I would pause, though, to suggest that you might not want to pad with zeros: you might want possibly want to replicate the edge pixels (unless the circles touch the edges.) I suggest that for the case where your background does not happen to be black (0's).
Paul Johnson
Paul Johnson 2011년 5월 23일
Thanks Walter, that's a big help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by