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

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..

matplotlib에는 imshow라는 method가 있는데 이 method는 array의 값들을 색으로 환산해 이미지의 형태로 보여줍니다. import numpy as np import matplotlib.pyplot as plt arr_test = np.array( [ # 1차 array [0, 1, 0], # 2차 array [1, 0, 1], [0, 1, 0], ] ) plt.imshow(arr_test) plt.show() 위 예시는 2차원 array를 imshow에 적용한 것입니다. 그 결과는 다음과 같습니다. 체스판 형태의 이미지가 나왔죠. 지금부터 왜 위처럼 된건지 알아봅시다. 일단 사용된 array를 보면 2차원이며 다음과 같습니다. [[0 1 0] [1 0 1] [0 1 0]] imsh..