■ ORB(Oriented FAST and Rotated BRIEF) 분류기를 사용하는 방법을 보여준다.
▶ 예제 코드 (PY)
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 |
import matplotlib import matplotlib.pyplot as pp import skimage.color as color import skimage.data as data import skimage.feature as feature import skimage.io as io import skimage.transform as transform matplotlib.use("TkAgg") io.use_plugin("matplotlib") imageNDArray = data.astronaut() grayscaleImageNDArray = color.rgb2gray(imageNDArray) rotateImageNDArray = transform.rotate(grayscaleImageNDArray, 180) affineTransform = transform.AffineTransform(scale=(1.3, 1.1), rotation = 0.5, translation = (0, -200)) transformImageNDArray = transform.warp(grayscaleImageNDArray, affineTransform) orb = feature.ORB(n_keypoints = 200) orb.detect_and_extract(grayscaleImageNDArray) grayscaleKeypointNDArray = orb.keypoints grayscaleDescriptorNDArray = orb.descriptors orb.detect_and_extract(rotateImageNDArray) rotateKeypointNDArray = orb.keypoints rotateDescriptorNDArray = orb.descriptors orb.detect_and_extract(transformImageNDArray) transformKeyPointNDArray = orb.keypoints transformDescriptorNDArray = orb.descriptors grayscaleRotateMatchNDArray = feature.match_descriptors(grayscaleDescriptorNDArray, rotateDescriptorNDArray , cross_check = True) grayscaleTransformMatchNDArray = feature.match_descriptors(grayscaleDescriptorNDArray, transformDescriptorNDArray, cross_check = True) figure, axesNDArray = pp.subplots(nrows = 2, ncols = 1) pp.gray() feature.plot_matches(axesNDArray[0], grayscaleImageNDArray, rotateImageNDArray, grayscaleKeypointNDArray, rotateKeypointNDArray, grayscaleRotateMatchNDArray) axesNDArray[0].axis("off") axesNDArray[0].set_title("Original Image vs. Transformed Image") feature.plot_matches(axesNDArray[1], grayscaleImageNDArray, transformImageNDArray, grayscaleKeypointNDArray, transformKeyPointNDArray, grayscaleTransformMatchNDArray) axesNDArray[1].axis("off") axesNDArray[1].set_title("Original Image vs. Transformed Image") pp.show() |