01.04.2015 Views

1FfUrl0

1FfUrl0

1FfUrl0

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Filtering for different effects<br />

The use of image processing to achieve pleasing effects in images dates back to<br />

the beginning of digital images, but it has recently been the basis of a number of<br />

interesting applications, the most well-known of which is probably Instagram.<br />

Chapter 10<br />

We are going to use a traditional image in image processing, the screenshot of the<br />

Lenna image, which is shown and can be downloaded from the book's website (or<br />

many other image-processing websites):<br />

im = mh.imread('lenna.jpg', as_grey=True)<br />

Adding salt and pepper noise<br />

We can perform many further manipulations on this result if we want to. For<br />

example, we will now add a bit of salt and pepper noise to the image to simulate<br />

a few scanning artifacts. We generate random arrays of the same width and height<br />

as the original image. Only 1 percent of these values will be true.<br />

salt = np.random.random(lenna.shape) > .975<br />

pepper = np.random.random(lenna.shape) > .975<br />

[ 207 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!