from skimage import data,filters
import matplotlib.pyplot as plt
img = data.camera()
edges = filters.sobel(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d5276510>
edges = filters.roberts(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d52e0590>
edges = filters.scharr(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d4111700>
edges = filters.prewitt(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d41bbbc0>
from skimage import data,filters,feature
import matplotlib.pyplot as plt
img = data.camera()
sigma=1
edges1 = feature.canny(img)
sigma=3
edges2 = feature.canny(img,sigma=3)
plt.figure('canny',figsize=(8,8))
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d5269580>
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
from skimage import data,filters
import matplotlib.pyplot as plt
img = data.camera()
filt_real, filt_imag = filters.gabor(img,frequency=0.6)
plt.figure('gabor',figsize=(8,8))
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
plt.subplot(121)
plt.title('filt_real')
plt.imshow(filt_real,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d409eba0>
plt.subplot(122)
plt.title('filt-imag')
plt.imshow(filt_imag,plt.cm.gray)
plt.show()
以上为 frequency=0.6
的结果图。
filt_real, filt_imag = filters.gabor(img,frequency=0.1)
plt.figure('gabor',figsize=(8,8))
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
plt.subplot(121)
plt.title('filt_real')
plt.imshow(filt_real,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45cf6fe4b0>
plt.subplot(122)
plt.title('filt-imag')
plt.imshow(filt_imag,plt.cm.gray)
plt.show()
from skimage import data,filters
import matplotlib.pyplot as plt
img = data.astronaut()
sigma=0.4
edges1 = filters.gaussian(img,sigma=0.4)
sigma=5
edges2 = filters.gaussian(img,sigma=5)
plt.figure('gaussian',figsize=(8,8))
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45cf6fd280>
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
from skimage import data,filters
import matplotlib.pyplot as plt
from skimage.morphology import disk
img = data.camera()
edges1 = filters.median(img,disk(5))
edges2= filters.median(img,disk(9))
plt.figure('median',figsize=(8,8))
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45d4103530>
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
from skimage import data,filters
import matplotlib.pyplot as plt
img = data.camera()
edges1 = filters.sobel_h(img)
edges2 = filters.sobel_v(img)
plt.figure('sobel_v_h',figsize=(8,8))
<Figure size 800x800 with 0 Axes>
<Figure size 800x800 with 0 Axes>
plt.subplot(121)
plt.imshow(edges1,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45cf23c2f0>
plt.subplot(122)
plt.imshow(edges2,plt.cm.gray)
plt.show()
import matplotlib.pyplot as plt
img =data.camera()
dst =filters.roberts_neg_diag(img)
plt.figure('filters',figsize=(8,8))
plt.subplot(121)
plt.title('origin image')
plt.imshow(img,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45ce883bc0>
plt.subplot(122)
plt.title('filted image')
plt.imshow(dst,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45cf1f8380>
另外一个核:
1 0
0 -1
对应函数为:
roberts_pos_diag(image)
import matplotlib.pyplot as plt
img =data.camera()
dst =filters.roberts_pos_diag(img)
plt.figure('filters',figsize=(8,8))
plt.subplot(121)
plt.title('origin image')
plt.imshow(img,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45ce7693d0>
plt.subplot(122)
plt.title('filted image')
plt.imshow(dst,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f45ce7a75f0>