Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
Agustin
Agustin le 15 Avr 2017
Commenté : Agustin le 17 Avr 2017
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 commentaire
Agustin
Agustin le 16 Avr 2017
Modifié(e) : Agustin le 16 Avr 2017
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.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 15 Avr 2017
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 commentaires
Image Analyst
Image Analyst le 16 Avr 2017
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 le 17 Avr 2017
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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by