■ hough_line 함수에서 Hough 변환을 사용해 직선 정보를 구하는 방법을 보여준다.
▶ 예제 코드 (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 56 57 58 59 60 61 62 63 64 |
import matplotlib from skimage import color from skimage import feature from skimage import io from skimage import transform matplotlib.use("TkAgg") io.use_plugin("matplotlib") imageNDArray = io.imread("source.png") grayscaleImageNDArray = color.rgb2gray(imageNDArray) lineTuple = transform.hough_line(grayscaleImageNDArray) print(lineTuple) """ (array([[0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0]], dtype=uint64), array([-1.57079633, -1.55334303, -1.53588974, -1.51843645, -1.50098316, -1.48352986, -1.46607657, -1.44862328, -1.43116999, -1.41371669, -1.3962634 , -1.37881011, -1.36135682, -1.34390352, -1.32645023, -1.30899694, -1.29154365, -1.27409035, -1.25663706, -1.23918377, -1.22173048, -1.20427718, -1.18682389, -1.1693706 , -1.15191731, -1.13446401, -1.11701072, -1.09955743, -1.08210414, -1.06465084, -1.04719755, -1.02974426, -1.01229097, -0.99483767, -0.97738438, -0.95993109, -0.9424778 , -0.9250245 , -0.90757121, -0.89011792, -0.87266463, -0.85521133, -0.83775804, -0.82030475, -0.80285146, -0.78539816, -0.76794487, -0.75049158, -0.73303829, -0.71558499, -0.6981317 , -0.68067841, -0.66322512, -0.64577182, -0.62831853, -0.61086524, -0.59341195, -0.57595865, -0.55850536, -0.54105207, -0.52359878, -0.50614548, -0.48869219, -0.4712389 , -0.45378561, -0.43633231, -0.41887902, -0.40142573, -0.38397244, -0.36651914, -0.34906585, -0.33161256, -0.31415927, -0.29670597, -0.27925268, -0.26179939, -0.2443461 , -0.2268928 , -0.20943951, -0.19198622, -0.17453293, -0.15707963, -0.13962634, -0.12217305, -0.10471976, -0.08726646, -0.06981317, -0.05235988, -0.03490659, -0.01745329, 0. , 0.01745329, 0.03490659, 0.05235988, 0.06981317, 0.08726646, 0.10471976, 0.12217305, 0.13962634, 0.15707963, 0.17453293, 0.19198622, 0.20943951, 0.2268928 , 0.2443461 , 0.26179939, 0.27925268, 0.29670597, 0.31415927, 0.33161256, 0.34906585, 0.36651914, 0.38397244, 0.40142573, 0.41887902, 0.43633231, 0.45378561, 0.4712389 , 0.48869219, 0.50614548, 0.52359878, 0.54105207, 0.55850536, 0.57595865, 0.59341195, 0.61086524, 0.62831853, 0.64577182, 0.66322512, 0.68067841, 0.6981317 , 0.71558499, 0.73303829, 0.75049158, 0.76794487, 0.78539816, 0.80285146, 0.82030475, 0.83775804, 0.85521133, 0.87266463, 0.89011792, 0.90757121, 0.9250245 , 0.9424778 , 0.95993109, 0.97738438, 0.99483767, 1.01229097, 1.02974426, 1.04719755, 1.06465084, 1.08210414, 1.09955743, 1.11701072, 1.13446401, 1.15191731, 1.1693706 , 1.18682389, 1.20427718, 1.22173048, 1.23918377, 1.25663706, 1.27409035, 1.29154365, 1.30899694, 1.32645023, 1.34390352, 1.36135682, 1.37881011, 1.3962634 , 1.41371669, 1.43116999, 1.44862328, 1.46607657, 1.48352986, 1.50098316, 1.51843645, 1.53588974, 1.55334303]), array([-1082., -1081., -1080., ..., 1080., 1081., 1082.])) """ |