Image downsampling
1) 개요
- Just deleting even rows and even columns occurs bad condition of images.


2) Aliasing
- Occurs when sampling rate is not high enough to capture the amount of detail in the image.
- Undersampling can disguise a signal as one of a lower frequency.


3) Anti-aliasing
- To avoid aliasing, sampling rate >= 2 * max frequency in the image (Nyquist rate)
- Apply a smoothing filter first, then downsample the image.

4) Gaussian image pyramid
- Used to downsample images.
- High level (low resolution), Low level (high resolution)
- Repeating smoothing filter (blur) -> subsampling

- Code (OpenCv)
src = cv.pyrUp(src, dstsize=(2 * cols, 2 * rows))
src = cv.pyrDown(src, dstsize=(cols // 2, rows // 2))
Image upsampling
1) Laplacian image pyramid
- Use to reconstruct an upsampled image from an image lower in the pyramid.
- Repeating upsampling -> sum with residual


- Code
lpA = [gpA[5]] # n번째 추가된 Gaussian Image
for i in xrange(5,0,-1):
GE = cv2.pyrUp(gpA[i]) #n번째 추가된 Gaussian Image를 Up Scale함.
temp = cv2.resize(gpA[i-1], (GE.shape[:2][1], GE.shape[:2][0])) # 행렬의 크기를 동일하게 만듬.
L = cv2.subtract(temp,GE) # n-1번째 이미지에서 n번째 Up Sacle한 이미지 차이 -> Laplacian Pyramid
lpA.append(L)
3) Image interpolation


F[x,y]=quantize(f(xd,yd))
- Interpolation is assuming the middle of known values.
- It is a discrete point-sampling of a continuous function.
- If we don't know the f(x), guess an approximation by convolution with a reconstruction filter, h.
˜f=h∗fF
Interpolation for warped image
If a rectangular ABCD with center P warped to A'B'C'D, calculate linear transformation 'T'.
And calculate P' with T -> execute interpolation.
- Various way of interpolation (Bicubic is common choise.)

- Code (OpenCV)
cv2.resize(image, size, fx, fy, interpolation)
cv2.resize(img, None, fx = 2.0, fy = 2.0, interpolation = cv2.INTER_CUBIC)
cv2.resize(img, None, fx = 2.0, fy = 2.0, interpolation = cv2.INTER_LINEAR)
ref.
docs.opencv.org/3.4/d4/d1f/tutorial_pyramids.html
www.cs.cmu.edu/~16385/lectures/lecture3.pdf
www.cs.cornell.edu/courses/cs5670/2019sp/lectures/lec03_resample.pdf