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 0x7fa977d93b00>
edges = filters.roberts(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7fa977e5dfd0>
edges = filters.scharr(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7fa977b30350>
edges = filters.prewitt(img)
plt.imshow(edges,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7fa9761b2750>
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 0x7fa977ab9fa0>
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 0x7fa9760c2c90>
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 0x7fa97613e1b0>
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 0x7fa975f9dca0>
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 0x7fa9760ae090>
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 0x7fa9753ff7a0>
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 0x7fa97516e900>
plt.subplot(122)
plt.title('filted image')
plt.imshow(dst,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7fa974fbe1b0>
另外一个核:
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 0x7fa974fd1430>
plt.subplot(122)
plt.title('filted image')
plt.imshow(dst,plt.cm.gray)
<matplotlib.image.AxesImage at 0x7fa975075be0>