File: plot_censure.py

package info (click to toggle)
skimage 0.25.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,720 kB
  • sloc: python: 60,007; cpp: 2,592; ansic: 1,591; xml: 1,342; javascript: 1,267; makefile: 168; sh: 20
file content (57 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
========================
CENSURE feature detector
========================

The CENSURE feature detector is a scale-invariant center-surround detector
(CENSURE) that claims to outperform other detectors and is capable of real-time
implementation.
"""

from skimage import data
from skimage import transform
from skimage.feature import CENSURE
from skimage.color import rgb2gray

import matplotlib.pyplot as plt


img_orig = rgb2gray(data.astronaut())
tform = transform.AffineTransform(
    scale=(1.5, 1.5), rotation=0.5, translation=(150, -200)
)
img_warp = transform.warp(img_orig, tform)

detector = CENSURE()

fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(12, 6))

detector.detect(img_orig)

ax[0].imshow(img_orig, cmap=plt.cm.gray)
ax[0].scatter(
    detector.keypoints[:, 1],
    detector.keypoints[:, 0],
    2**detector.scales,
    facecolors='none',
    edgecolors='r',
)
ax[0].set_title("Original Image")

detector.detect(img_warp)

ax[1].imshow(img_warp, cmap=plt.cm.gray)
ax[1].scatter(
    detector.keypoints[:, 1],
    detector.keypoints[:, 0],
    2**detector.scales,
    facecolors='none',
    edgecolors='r',
)
ax[1].set_title('Transformed Image')

for a in ax:
    a.axis('off')

plt.tight_layout()
plt.show()