■ threshold_otsu 함수를 사용해 이미지 임계를 처리하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import matplotlib from skimage import color from skimage import filters from skimage import io matplotlib.use("TkAgg") io.use_plugin("matplotlib") imageNDArray = io.imread("source.png") grayscaleImageNDArray = color.rgb2gray(imageNDArray) threshValue = filters.threshold_otsu(grayscaleImageNDArray) threshImageNDArray = grayscaleImageNDArray > threshValue io.imshow(threshImageNDArray) io.show() |