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

4 次查看(过去 30 天)
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