1. 곡선의 접선
- 미분계수란 y=f(x)의 접선의 기울기
2. 윤곽 추출하기
- 명암차가 급격한 곳을 보고 영영과 영역의 관계를 파악 = 윤곽을 파악
- 값의 변화를 보는 방법 = 뺄셈

%matplotlib inline
import matplotlib.pyplot as plt
from PIL import Image
src_img = Image.open('sample.png') #이미지를 읽어들인다
plt.imshow(src_img)
plt.show()
width, height = src_img.size #이미지의 크기를 조정한다
dst_img = Image.new('RGB', (width, height)) #출력을 위해 영역 할당
src_img = src_img.convert("L") #컬러에서 흑백으로 전환해라
#윤곽을 추출하는 방법
for y in range(0, height-1):
for x in range(0, width-1):
diff_x = src_img.getpixel((x+1, y)) - src_img.getpixel((x, y))
diff_y = src_img.getpixel((x, y+1)) - src_img.getpixel((x, y))
diff = diff_x + diff_y
#출력
if diff >=20:
dst_img.putpixel((x, y), (255, 255, 255))
else:
dst_img.putpixel((x, y), (0, 0, 0))
plt.imshow(dst_img)
plt.show()'파이썬으로 다시 배우는 핵심고등수학 (python) > 08장 : 미분과 적분' 카테고리의 다른 글
| 8-3. 적분이란 (0) | 2021.03.01 |
|---|---|
| 8-2. 미분이란 (0) | 2021.03.01 |
| 8-1. 곡선과 그래프 (0) | 2021.03.01 |