We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
so1a/2019 Mathworks Learning Tool
Image blur
Write a function called blur that blurs the input image. The function is to be callled like this:
output
blur (img,w) ;
where img, the input image is a two-dimensional matrix of grayscale pixel values between 0 and 256.
Blurring is to be carried out by averaging the pixel values in the vicinity of every pixel. Specifically, the
output pixel value is the mean of the pixels in a square submatrix of size 2w#1 where the given pixel sits,
in the center. For example, if w is 1, then we use a 3x3 matrix, that is, we average all the neighboring
pixels of the given pixel and itself. Only use valid pixels when portions of the blurring matrix fall outside the
image. For example, the blurred value corresponding to w = 1 at index (1,1) would be the mean of of
elements (1,1), (1, 2), (2,1) and (2, 2). Both input img and output output are of type uint8.
You can download the test image here (https://Icms-files.mathworks.com/contentifile/686475c-bd78-
497d-b971-b583832bb123/vandy.png?versionid=ZUe0hS9J3ZIxKapgDPNMdw_Uvjotsiaf) to use in
MATLAB.
Function
Reset BH MATLAB Documentation (https:/;www.mathworks.com/help/)
Fry
a
2
a3
as
as
16
v
a8
a9
20
a
22
23
28
2s
26
hitps:learninglooL mathworks.corviaunch
12so1a2019 Mathworks Learning Tool
2g | function output = blur(img,w)
Code to call your function
2 img = imread(’vandy.png");
2 output = blur(ing,2);
3. imshow(output)
Output
VANDERBILT
UNIVERSITY®
Assessment: All Tests Passed
C Reset
30
@ Simple test
@ Using image file
hitps:learninglooL mathworks.corviaunch
22