In digital image processing, we use different filters to transform or improve the image’s size, color, and other characteristics. One of them is the weighted average filter, in which pixels are multiplied by different numbers. This gives more weightage to some pixels at the expense of others. We give more weight and importance to the center value. Then, it is multiplied by a higher value than any other value in the mask. This gives this pixel a higher contribution and impact than the other pixels. It also helps us to control the blurriness of the image.
When we apply this filter to an image, it blurs the image and removes the noise from it. It is also used to reduce details, such as sharpness, edges, and so on.
An example of the weighted average filter is given below.
img_1=imread("/lena_gray.jpeg");mask=1/16*[1,2,1;2,4,2;1,2,1];img_2=filter2(mask,img_1);Plot=imshow([img_1, img_2]);
imread()
to read the image and return the image data in img_1
.mask
.filter2()
, to apply the filter mask
on img_1
and store the filtered image in img_2
.imshow
function to plot both the original and the blurred image side by side using.Free Resources