Conda backup for DIP 2021
·
Programming/DIP
Pre-requirements conda : 4.10.3 (miniconda) yml file : 참고 conda env export --from-history > dip2021.yml cmd conda env create -f dip2021.yml dip라는 이름의 virtual env 생성됨. opencv, matplotlib, scikit-image, jupyterlab, git 등의 패키지 설치됨. 삭제하기 설치한 virtual env 삭제하려면 다음을 수행. codna env remove -n dip References Exporting an environment file across platforms(conda.io)
NumPy : sum, mean, std, and so on
·
Programming/DIP
영상을 처리할 때, 영상의 각 pixel intensity에 대해 다양한 통계처리가 필요함. NumPy는 자체적으로 다양한 통계처리 함수들 (집계함수, 또는 Aggregation Function 이라고 불림) 을 제공함. 참고로, 영상 데이터에서는 pixel (or element)의 값이 NaN인 경우가 거의 없으나 다른 matrix나 tensor 데이터의 경우에는 NaN 인 원소를 가질 수 있음. 이 경우, NaN Safe Aggregation Functions를 사용하여 NaN은 무시하고 값을 구할 수 있음. https://ds31x.tistory.com/223 [Tensor] NaN Safe Aggregation Functions NaN (Not a Number) 값을 포함하는 Tensor 인스턴스..
NumPy 검색
·
Programming/DIP
np.wherenumpy.where(condition[, x, y]) :Return elements chosen from x or y depending on condition.condition : 검색에 사용될 조건.x : condition이 True에 해당하는 위치에 지정되는 값 또는 array (검색에 사용된 ndarray로 broadcast처리 가능한 shape이어야 함)y : condition이 False에 해당하는 위치에 지정되는 값 또는 array (검색에 사용된 ndarray로 broadcast처리 가능한 shape이어야 함)반환값x,y를 설정해준 경우엔 조건에 따라 해당 값으로 채워진 ndarray임.아닌 경우, condition에 True에 해당하는 위치의 idx. ndim 2인 ndar..
NumPy 배열 나누기: 영상 자르기
·
Programming/DIP
1. numpy.vsplitnumpy.vsplit(array, indices_or_sections) : Split an array into multiple sub-arrays vertically (row-wise)axis 0 (행)로 array를 잘라 나눔.array가 image라면 수직으로 잘려진다.Simple exampleimport numpy as npa = np.arange(12).reshape(-1,3)np.vsplit(a, (1,3)) 이 경우, idx 0인 행으로 구성된 1x3인 ndarray, idx 1,2 행들이 묶인 2x3인 ndarray, 그리고 idx 3인 행으로 구성된 1x3인 ndarray로 나누어짐np.vsplit(a, (1,3))의 반환값은 list임.[array([[0, 1..
NumPy 배열 병합 : 영상 붙이기
·
Programming/DIP
1. numpy.vstacknumpy.vstack(tup) : Stack arrays in sequence vertically (rowwise)axis 0로 ndarray들을 붙임2d image라면 위아래로 붙여지게 됨.Simple exampleimport numpy as npa = np.ones((4,3))b = np.zeros((4,3))np.vstack( (a,b) )Image exampleimport cv2import matplotlib.pyplot as pltimg = cv2.imread('../../images/lena.png')stacked_img = np.vstack((img,img))plt.imshow(stacked_img[:,:,::-1])plt.show() 결과는 다음과 같음.ref:..