[DIP] Deconvolution: Richardson-Lucy deconvolution algorithm
·
Programming/DIP
Deconvolution : Richardson-Lucy deconvolution algorithmImage Restoration의 대표적인 예이기도 함. Blurring을 결정하는 PSF (blur kenel이라고도 불림)가 알려진 경우 사용되는 non-blind deblurring algorithm의 대표적 기법.The algorithm is based on a PSF (Point Spread Function), where PSF is described as the impulse response of the optical system.The blurred image is sharpened through a number of iterations, which needs to be hand-tuned.단점..
[NumPy] Fancy Indexing & Combined Indexing
·
Programming/DIP
IndexingNumPy에서 indexing은 4+1 가지 방식을 따름.scalar를 이용한 indexing ( simple indexing ) : array[0]slicingboolean mask : array[array > 1]fancy indexing : vectorized indexing. index들을 element로 가지는 array를 넘겨줌.combined indexing : 앞서 4가지가 조합된 indexingfancy indexing의 경우, PyTorch 에서는 Tensor-based Indexing 또는 Advanced Indexing이라고도 불림. scalar를 이용한 indexing과 slicing, boolean mask를 이용한 indexing은 다음 글을 참고: https:/..
[DIP] OpenCV : Region of Interest (ROI) : Callback으로 구현.
·
Programming/DIP
cv2.selectROI가 아닌 이벤트 핸들러(MouseCallback)를 이용한 구현임.x button (or close button)을 지원하기 위한 구현을 추가.x 키를 누를 경우, roi를 보여주는 창만 닫히도록 처리함.esc 키를 누를 경우, 프로그램 종료.import cv2import numpy as npis_dragging = Falsex0,y0 = -1,-1w0,h0 = -1,-1red = (0,0,255)exit_roi = Falseimport osd_path = os.path.dirname(__file__)f_path = os.path.join(d_path,"lena.png")def onMouse(event, x, y, flags, param): global is_dragging ..
[DIP] opencv : Region of Interest (ROI) : cv2.selectROI
·
Programming/DIP
cv2에서 사각형의 ROI를 선택하는 가장 쉬운 방법. Signatureret_val = cv2.selectROI( [window_name], img [, showCrossHair=True, fromCenter=False] )window_name : ROI 선택을 수행할 window이름. strimg : 보여질 이미지.showCrossHair : ROI 중심에 십자모양 표시 여부fromCenter : 마우스 시작지점을 영역의 중심으로 간주ret_val = (x,y,w,h) of ROISample codeimport cv2import numpy as npimport osd_path = os.path.dirname(__file__)img_path = f'{d_path}/lena.pn..
[NumPy] Broadcasting
·
Programming/DIP
0. Broadcasting이란?tensor와 scalar를 연산시킬 때 scalar를 상대 tensor와 같은 shape이면서 해당 scalar의 값을 가진 tensor로 변경시키고나서 이 scalar로부터 만들어진 tensor와 상대 tensor를 동작시키는 방식으로 elementwise연산이 수행되는 기능. 주의할 것은 scalar 를 확장시키는 것이 기본이라는 점임.  참고로 broadcasting은 scalar와 tensor간의 연산을 확장하여 차원이 다른 tensor간의 연산에도 사용된다:단, scalar에서 출발하므로 size가 1인 축(=scalar)을 추가하는 padding을 이용함. PyTorch나 TensorFlow의 텐서도 NumPy와 같은 방식으로 broadcasting이 수행된다..
[DIP] Signal to Noise : Amplitude, Power, and Differential SNR
·
Programming/DIP
Amplitude SNR 가장 흔하게 사용되는 SNR. signal 의 amplitude와 noise의 amplitude의 ratio. $$\text{SNR}_a=\frac{\text{Amplitude(S)}}{\text{Amplitude(N)}}$$ $S$ : signal. $N$ : noise 주의할 점은 무엇을 signal로 볼지, noise로 볼지는 해당 분야의 상황에 맞춰서 잘 정해야 함. (case dependent) deciBel로 계산시 $$ 20\log_{10}(\text{SNR}_a)$$ 로 계산된다. Power SNR power를 이용함. 보통 amplitude에 비해 squared 된 게 power인 점을 잊지 말자. $$\text{SNR}_p=\frac{\text{Power(S)}..