Skip to content

Commit 129ecd4

Browse files
committed
add unsharpen example.
1 parent 4cf5f37 commit 129ecd4

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

examples/unsharp.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from PIL import Image
2+
from pylab import *
3+
from scipy.ndimage import filters
4+
5+
6+
"""
7+
This is an example of unsharp masking using Gaussian blur.
8+
"""
9+
10+
# load sample eye image from http://en.wikipedia.org/wiki/Unsharp_masking
11+
im = array(Image.open("unsharpen.jpg").convert("L"), "f")
12+
13+
# create blurred version of the image
14+
sigma = 3
15+
blurred = filters.gaussian_filter(im,sigma)
16+
17+
# create unsharp version (no thresholding)
18+
weight = 0.25
19+
unsharp = im - 0.25*blurred
20+
21+
22+
# plot the original and the unsharpened image
23+
figure()
24+
imshow(im)
25+
gray()
26+
title("original image")
27+
28+
figure()
29+
imshow(unsharp)
30+
gray()
31+
title("unsharp mask with weight {}".format(weight))
32+
33+
show()

examples/unsharpen.jpg

16 KB
Loading

0 commit comments

Comments
 (0)