파이썬(python)을 이용한 이미지 데이터 호출, 수정 처리에 대한 실행 코드를 정리합니다. 포스팅 하단에 실행 코드 파일도 업로드해두겠습니다. 해당 파일 내려받고 연습하기 바랍니다.
이미지 데이터 호출
from skimage.io import imread
from skimage.transform import resize
from matplotlib import pyplot as plt
import matplotlib.cm as cm
file = ("C:/test/py/data01/soldier.jpg")
image = imread(file)
plt.imshow(image)
plt.show()
이미지 변환 : 회색
from skimage.io import imread
from skimage.transform import resize
from matplotlib import pyplot as plt
import matplotlib.cm as cm
file = "C:/test/py/data01/soldier.jpg"
image = imread(file, as_gray=True) # 수정된 부분
plt.imshow(image, cmap=cm.gray)
plt.show()
이미지 변환 : 기타 다양한 처리
from PIL import Image
from PIL import ImageFilter
img = Image.open('C:/test/py/data01/soldier.jpg')
img1 = img.filter(ImageFilter.BLUR)
img2 = img.filter(ImageFilter.EMBOSS)
img3 = img.filter(ImageFilter.CONTOUR)
img1.show()
img2.show()
img3.show()
이미지 자르기
from PIL import Image
img = Image.open("C:/test/py/data01/soldier.jpg")
img_cropped = img.crop((100, 100, 1000, 1000))
img_cropped.show()
이미지 확대
from skimage.io import imread
from skimage.transform import resize
from matplotlib import pyplot as plt
import matplotlib.cm as cm
file = ("C:/test/py/data01/soldier.jpg")
image01 = imread(file)
image02 = image01[100:1000, 100:1000]
plt.imshow(image02)
plt.show()
파일 다운로드
실행 파일을 업로드해둡니다.
추가 정보
[1] 10 Python image manipulation tools
10 Python image manipulation tools
These Python libraries provide an easy and intuitive way to transform images and make sense of the underlying data.
opensource.com
[2] Image Processing with Python
Image Processing with Python
As computer systems have become faster and more powerful, and cameras and other imaging systems have become commonplace in many other areas of life, the need has grown for researchers to be able to process and analyse image data. Considering the large volu
datacarpentry.org
'교육' 카테고리의 다른 글
ChatGPT API Key │ChatGPT R에서 사용하기 (0) | 2023.03.20 |
---|---|
워드클라우드 간단 예제 │파이썬 │Python (0) | 2023.03.20 |
베이지크 국내 비건 스킨케어 일본 사용 후기 텍스트 마이닝 분석 사례│ 아마존 재팬 (0) | 2023.01.10 |
무료 코딩 없는 웹스크래핑 텍스트 마이닝 데이터 시각화│일본 유기농 립스틱 아마존 재팬 현지 고객 리뷰 사례 분석 (0) | 2023.01.09 |
ChatGPT과 구글 동시 활용하는 방법 │ChatGPT 크롬 익스텐션 설치 │일본 비건 스킨케어 브랜드 추천 품목 찾기 (0) | 2023.01.02 |