시작하기무료로 시작하기

엣지 검출

이번 연습에서는 Sobel 필터를 적용해 이미지에서 엣지를 검출해 보겠습니다.

파란 배경 위 하트와 직사각형 모양의 비누 알약
이미지는 soaps_image로 미리 로드되어 있습니다.

show_image() 함수도 이미 로드되어 있습니다.

이제 이미지 속 모든 도형을 잘 찾아내는지 확인해 볼까요?

이 연습은 강의의 일부입니다

Python으로 배우는 이미지 처리

강의 보기

연습 안내

  • 이미지를 그레이스케일로 변환할 수 있도록 color 모듈을 import하세요.
  • filters 모듈에서 sobel() 함수를 import하세요.
  • color 모듈의 적절한 메서드를 사용해 soaps_image를 그레이스케일로 변환하세요.
  • 얻어진 그레이스케일 이미지 soaps_image_gray에 Sobel 엣지 검출 필터를 적용하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Import the color module
from ____ import ____

# Import the filters module and sobel function
from skimage.____ import ____

# Make the image grayscale
soaps_image_gray = ____.____(soaps_image)

# Apply edge detection filter
edge_sobel = ____(____)

# Show original and resulting image to compare
show_image(soaps_image, "Original")
show_image(edge_sobel, "Edges with Sobel")
코드 편집 및 실행