일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- numpy
- Mac
- PySpark
- matplotlib
- django
- array
- list
- Tkinter
- Apache
- google apps script
- Java
- PostgreSQL
- math
- Excel
- GIT
- PANDAS
- SQL
- hive
- dataframe
- Kotlin
- string
- gas
- 파이썬
- Redshift
- Python
- Github
- c#
- Google Spreadsheet
- Google Excel
- Today
- Total
목록image (4)
달나라 노트

opencv는 이미지 처리 기능, 머신러닝 등의 기능을 제공하는 툴 입니다. opencv를 이용해 간단하게 원하는 크기의 원하는 색상의 이미지를 만들어봅시다. 이를 위해선 numpy array가 필요합니다. import numpy as npimport cv2arr_for_img = np.zeros(shape=(800, 500), dtype=float) # 행 개수 800개, 열 개수 500개의 0으로 채워진 2차원 array 생성print(arr_for_img)cv2.imwrite('img_black.png', arr_for_img) # array를 이용하여 png image 생성-- Result[[0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. ..

matplotlib는 굉장히 재미있는 기능들을 제공하는데 그 중에선 image 파일을 읽어서 그래프로 나타내주는 기능을 제공합니다. 제가 이전에 먹었던 녹차빙수 사진을 한번 matplotlib를 이용해서 그래프 위에 나타내보겠습니다. import matplotlib.pyplot as plt import matplotlib.image as img img_test = img.imread('greentea_ice_flakes.png') plt.imshow(img_test) plt.show() directory 구조는 위와 같습니다. pyplot.py 파일에 위 예시코드가 적혀있으며 greentea_ice_flakes.png 파일이 바로 제가 먹었던 녹차빙수 사진입니다. - img_test = img.imrea..
Python을 이용해 image 파일을 pdf로 변환하는 방법을 알아봅시다. pip install PIL pip install Pillow 사용되는 라이브러리는 PIL 입니다. PIL이 간혹 설치가 제대로 되지 않는 경우가 있을 수 있는데 그럴 땐 Pillow 패키지를 설치합시다. (Pillow 패키지를 설치해도 PIL 라이브러리는 이용할 수 있습니다.) from PIL import Image img = Image.open(r'test/img_test_1.png') img_rgb = img.convert('RGB') img_rgb.save('test/pdf_test_1.pdf') 위 예시는 test directory에 있는 img_test_1.png라는 이미지파일을 test directory안에 pdf_..

image를 ASCII character를 이용한 그림으로 변환할 수 있습니다. 변환할 image인 apple.png는 다음과 같습니다. apple 로고를 변환해볼게요. import PIL.Image # list of ascii characters used when convert image to ascii text list_ascii_chars = ['@', '#', 'S', '%', '?', '*', '+', ';', ':', ',', '.'] # resize image according to a new width def resize_image(pil_obj_image, new_width): width, height = pil_obj_image.size # obj_image = image object ..