How can I move a 7x7 filter around an image?

조회 수: 1 (최근 30일)
Agustin
Agustin 2017년 4월 15일
댓글: Agustin 2017년 4월 17일
So I have an estimated filter, theta, to apply it to a blurred image. For each pixel on the image I have to do the following:
ys = zs * theta
Where zs is a 7x7 window sorrounding pixel s and theta is the minimum square error to adjust the blurred image. How can I move the 7x7 window filter around the image, especially when I select pixels that are located at the edge of the image?
  댓글 수: 1
Agustin
Agustin 2017년 4월 16일
편집: Agustin 2017년 4월 16일
Well, zs is the one that I need to work on. zs is a row vector of a set of pixels that belong to a window surrounding pixel s in the blurred image X. I need to evaluate the 7 x 7 window on each pixel but I'm not sure what I need to do when I select a pixel that is for example, on the top left corner of the image. Once I have zs I know what to do. ys = zs * theta is for one pixel. ys is the pixel of an image Y.

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

답변 (1개)

Image Analyst
Image Analyst 2017년 4월 15일
For a simple multiplication, you can use conv2(). Assuming zs is the 2-D input image:
ys = conv2(zs, imrotate(theta, 180), 'same');
If zs is uint8 or uint16, cast to double before you pass it to conv2():
ys = conv2(double(zs), imrotate(theta, 180), 'same');
or use imfilter():
ys = imfilter(zs, theta);
  댓글 수: 3
Image Analyst
Image Analyst 2017년 4월 16일
If zs is a row vector - one complete row from an image - then ys is also a row vector since you're just multipling it by a scalar theta. So where does the 7x7 window come into play? And anyway, how do you apply a 7x7 2-D square window to a 1-D vector?
Agustin
Agustin 2017년 4월 17일
zs is a 7x7 window of pixels surrounding pixel s. After I have my window, I reshape it so it becomes a 1 x 49 row vector. Theta is a 49 x 1 vector. so zs * theta should give one value for each pixel in Y.

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

Community Treasure Hunt

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

Start Hunting!

Translated by