본문 바로가기

Aiffel_learning/Data_analysis

1-1. NumPy 활용하기(audio, image)

https://jalammar.github.io/visual-numpy/

 

A Visual Intro to NumPy and Data Representation

Discussions: Hacker News (366 points, 21 comments), Reddit r/MachineLearning (256 points, 18 comments) Translations: Chinese 1, Chinese 2, Japanese, Korean The NumPy package is the workhorse of data analysis, machine learning, and scientific computing in t

jalammar.github.io

 

컴퓨터는 2진수로 이루어진 산술 연산만 가능하기 때문에 데이터(영상, 이미지, 텍스트, 소리 등)을 숫자로 표현하여 계산하기 때문에 NumPy를 활용하면 좋음

 

audio

- 1차원 ndarray
- CD 음원파일 기준 44.1kHz(초당 44100개)의 -32767 ~ 32768 정수 값을 가

 

image

- 2차원 ndarray
- 픽셀별로 명도(grayscale)를 0(black)~255(white)로 환산한 숫자 1개의 튜플값을 가짐
- color의 경우 RGB값으로 된 3개 요소의 튜플로 구성, 투명도 까지 해서 RGBA, 4개로 표시하기도 함

*matplotlib, pil(pillow)를 사용해서 image ndarray로 변경, 흑색으로 색상변경, 사진 불러오기, crop, 사진 저장하기 등 수행가능

https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes

 

Concepts

The Python Imaging Library handles raster images; that is, rectangles of pixel data. Bands: An image can consist of one or more bands of data. The Python Imaging Library allows you to store several...

pillow.readthedocs.io