View the step-by-step solution to:

Question

# Why does this code not work

where the noise occurs in small, horizontal lines.

A 1 from skimage import data, io
A
2 from scipy import ndimage
3 import numpy as np
4 import skimage as ski
5
6 # Load in the test image
7 a=io. imread (&quot;a_noise. png&quot;, \
8
as_gray=True)
9 a=ski. ing_as_float64(a)
10 a*=1/ (a [: ] . max () )
11
12 # Initialize a copy of the image
13 (y, x)=a . shape
14 b=np. copy (a)
15
16
17 for j in range(1, y-1):
18
for i in range(1, x-1) :
19
20
# Create list of nearby points
21
1=[a[j, i] , a[j+1, i] , a[j-1, i] , a[j, i-1], a[j, i+1]]
22
23
# Set output pixel to be median
24
# of the list
25
b[j , i]=np. median( 1)
26
27
28
29 # Plot the image
30 io. imsave(&quot;a_denoise. png&quot; , b)
31 |

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents