numpy

    NumPy 배열 나누기: 영상 자르기

    1. numpy.vsplit numpy.vsplit(array, indices_or_sections) : Split an array into multiple sub-arrays vertically (row-wise) axis 0 (행)로 array를 잘라 나눔. array가 image라면 수직으로 잘려진다. Simple example import numpy as np a = 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임. [arr..

    NumPy 배열 병합 : 영상 붙이기

    1. numpy.vstack numpy.vstack(tup) : Stack arrays in sequence vertically (rowwise) axis 0로 ndarray들을 붙임 2d image라면 위아래로 붙여지게 됨. Simple example import numpy as np a = np.ones((4,3)) b = np.zeros((4,3)) np.vstack( (a,b) ) Image example import cv2 import matplotlib.pyplot as plt img = cv2.imread('../../images/lena.png') stacked_img = np.vstack((img,img)) plt.imshow(stacked_img[:,:,::-1]) plt.show() ..