CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

Tutorials

Views: 1388
1
2
# coding: utf-8
3
4
# ## Image processing
5
#
6
# Python offers many tools for image processing using the [SciKit module](http://scikit-image.org/)
7
8
# In[1]:
9
10
11
# load modules
12
import numpy as np
13
from skimage import data
14
import matplotlib.pyplot as plt
15
16
17
# In[2]:
18
19
20
# load standard image
21
camera = data.camera()
22
23
# plot
24
plt.imshow(camera,cmap='gray')
25
26
27
# In[3]:
28
29
30
# images are numerical arrays
31
camera[0:50,0:50] = 0
32
33
#
34
plt.imshow(camera,cmap='gray')
35
36
37
# In[4]:
38
39
40
# filtering
41
from skimage.morphology import disk
42
from skimage.filters import gaussian
43
44
selem = disk(20)
45
blurred = gaussian(camera, sigma=(10,10))
46
47
plt.imshow(blurred,cmap='gray')
48
49
50
# In[10]:
51
52
53
# load standard image
54
camera = data.camera()
55
camera = camera + 100*np.random.random(camera.shape)
56
# plot
57
plt.imshow(camera,cmap='gray')
58
59
60