In [2]:
from skimage import data,filters
import matplotlib.pyplot as plt
In [3]:
img = data.camera()
edges = filters.sobel(img)
plt.imshow(edges,plt.cm.gray)
Out[3]:
<matplotlib.image.AxesImage at 0x7fa977d93b00>
In [4]:
edges = filters.roberts(img)
plt.imshow(edges,plt.cm.gray)
Out[4]:
<matplotlib.image.AxesImage at 0x7fa977e5dfd0>
In [5]:
edges = filters.scharr(img)
plt.imshow(edges,plt.cm.gray)
Out[5]:
<matplotlib.image.AxesImage at 0x7fa977b30350>
In [6]:
edges = filters.prewitt(img)
plt.imshow(edges,plt.cm.gray)
Out[6]:
<matplotlib.image.AxesImage at 0x7fa9761b2750>
In [7]:
from skimage import data,filters,feature
import matplotlib.pyplot as plt
In [8]:
img = data.camera()
sigma=1
In [9]:
edges1 = feature.canny(img)
sigma=3
In [10]:
edges2 = feature.canny(img,sigma=3)
In [11]:
plt.figure('canny',figsize=(8,8))
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
Out[11]:
<matplotlib.image.AxesImage at 0x7fa977ab9fa0>
In [12]:
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
In [13]:
from skimage import data,filters
import matplotlib.pyplot as plt
In [14]:
img = data.camera()
filt_real, filt_imag = filters.gabor(img,frequency=0.6)
In [15]:
plt.figure('gabor',figsize=(8,8))
Out[15]:
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
In [16]:
plt.subplot(121)
plt.title('filt_real')
plt.imshow(filt_real,plt.cm.gray)
Out[16]:
<matplotlib.image.AxesImage at 0x7fa9760c2c90>
In [17]:
plt.subplot(122)
plt.title('filt-imag')
plt.imshow(filt_imag,plt.cm.gray)
plt.show()
以上为 frequency=0.6 的结果图。
In [18]:
filt_real, filt_imag = filters.gabor(img,frequency=0.1)
In [19]:
plt.figure('gabor',figsize=(8,8))
Out[19]:
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
In [20]:
plt.subplot(121)
plt.title('filt_real')
plt.imshow(filt_real,plt.cm.gray)
Out[20]:
<matplotlib.image.AxesImage at 0x7fa97613e1b0>
In [21]:
plt.subplot(122)
plt.title('filt-imag')
plt.imshow(filt_imag,plt.cm.gray)
plt.show()
In [22]:
from skimage import data,filters
import matplotlib.pyplot as plt
In [23]:
img = data.astronaut()
sigma=0.4
In [24]:
edges1 = filters.gaussian(img,sigma=0.4)
sigma=5
In [25]:
edges2 = filters.gaussian(img,sigma=5)
In [26]:
plt.figure('gaussian',figsize=(8,8))
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
Out[26]:
<matplotlib.image.AxesImage at 0x7fa975f9dca0>
In [27]:
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
In [28]:
from skimage import data,filters
import matplotlib.pyplot as plt
from skimage.morphology import disk
In [29]:
img = data.camera()
edges1 = filters.median(img,disk(5))
edges2= filters.median(img,disk(9))
In [30]:
plt.figure('median',figsize=(8,8))
Out[30]:
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
In [31]:
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
Out[31]:
<matplotlib.image.AxesImage at 0x7fa9760ae090>
In [32]:
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
In [33]:
from skimage import data,filters
import matplotlib.pyplot as plt
In [34]:
img = data.camera()
edges1 = filters.sobel_h(img)
edges2 = filters.sobel_v(img)
In [35]:
plt.figure('sobel_v_h',figsize=(8,8))
Out[35]:
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
In [36]:
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
Out[36]:
<matplotlib.image.AxesImage at 0x7fa9753ff7a0>
In [37]:
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
In [38]:
import matplotlib.pyplot as plt
In [39]:
img =data.camera()
dst =filters.roberts_neg_diag(img)
In [40]:
plt.figure('filters',figsize=(8,8))
plt.subplot(121)
plt.title('origin image')
plt.imshow(img,plt.cm.gray)
Out[40]:
<matplotlib.image.AxesImage at 0x7fa97516e900>
In [41]:
plt.subplot(122)
plt.title('filted image')
plt.imshow(dst,plt.cm.gray)
Out[41]:
<matplotlib.image.AxesImage at 0x7fa974fbe1b0>
另外一个核:
1 0
0 -1对应函数为:
roberts_pos_diag(image)In [42]:
import matplotlib.pyplot as plt
In [43]:
img =data.camera()
dst =filters.roberts_pos_diag(img)
In [44]:
plt.figure('filters',figsize=(8,8))
plt.subplot(121)
plt.title('origin image')
plt.imshow(img,plt.cm.gray)
Out[44]:
<matplotlib.image.AxesImage at 0x7fa974fd1430>
In [45]:
plt.subplot(122)
plt.title('filted image')
plt.imshow(dst,plt.cm.gray)
Out[45]:
<matplotlib.image.AxesImage at 0x7fa975075be0>