이 문서는
Numerator Layout Convention 을 사용함.
Hessian : Summary
2nd order derivative of multivariable function.
- 여기서 multivariable function은 입력은 vector, 출력은 scalar 인 함수를 의미함: ML에서의 loss function을 생각해 볼 것.
Hessian matrix $H[f](\textbf{x})$는 다음과 같음.
$$\begin{aligned}H[f](\textbf{x})=H(\textbf{x})&=\left(J\left[\nabla f(\textbf{x})\right]\right)^\top \\ &= \begin{bmatrix}\dfrac{\partial^2 f}{\partial x_1^2} (\textbf{x})& \dfrac{\partial^2 f}{\partial {x_1} \partial{x_2}} (\textbf{x})& \cdots & \dfrac{\partial^2 f}{\partial {x_1}\partial{x_n}}(\textbf{x})\\ \dfrac{\partial^2 f}{\partial {x_2} \partial{x_1}} (\textbf{x})& \dfrac{\partial^2 f}{\partial x_2^2 } (\textbf{x})& \cdots & \dfrac{\partial^2 f}{\partial {x_2}\partial{x_n}}(\textbf{x})\\ \vdots & \vdots & \ddots & \vdots \\ \dfrac{\partial^2 f}{\partial {x_n} \partial{x_1}} (\textbf{x})& \dfrac{\partial^2 f}{\partial {x_n} \partial{x_2}} (\textbf{x})& \cdots & \dfrac{\partial^2 f}{\partial x_n^2} (\textbf{x})\end{bmatrix}\end{aligned}$$
where
- $J\left[ \quad \right]$는 Jacobian 의미.
- $\nabla f(\textbf{x})$는 Gradient를 의미.
Hessian matrix의 $(i,j)$ 요소의 general form은 다음과 같음.
$$
H_{ij}=\dfrac{\partial^2 f}{\partial x_i \partial x_j}
$$
Eigen decomposition 과 Curvature
Hessian matrix 는 $f$가 이차미분가능하고 이차미분 도함수가 연속인 경우 구해지며 항상 symmetric matrix 임.
- This is in general only true, if the second partial derivatives are continuous.
- This is called Schwarz's theorem (or Clairaut's Theorem).
- $f$가 두 번 미분 가능하며, 이차미분 결과 도함수가 연속인 경우, 다음이 성립함: $\frac{\partial ^2 f}{\partial x_i x_ j } = \frac{\partial ^2 f}{\partial x_j x_i}$
- Symmetric matrix 는 항시 eigen decomposition이 가능함.
- $n \times n$ Hessian matrix는 항시 Symmetric matrix가 되므로 orthonormal eigen vector를 $n$개 가짐.
Hessian 행렬의
1. 고유벡터(eigenvector)는 대상 multivariable function의 곡률(curvature)이 큰 방향벡터 에 해당.
2. 고유값(eigenvalue)은 해당 고유벡터(eigenvector) 방향으로의 함수의 곡률(curvature, 이차미분값)임.
- 해당 값의 크기(absolute value)은 convex 등에서 그래프의 폭을 결정함.
- 클수록 폭이 좁음. (= curvature, 곡률이 큼)
이 같은 성질 때문에 Hessian matrix의 determinant는 SURF (Speed-Up Robust Features)에서 keypoint를 검출하는데 사용됨:
- 곡률이 큰 corner 등의 부분에서 Hessian matrix의 determinant가 커짐.
- 주변 pixel들과 다른 값을 가지는 변화가 큰 keypoint 에서는 eigen value가 크고 이는 큰 determinant로 이어짐.
- $\text{det}(H)=\prod^n_{i=1} \lambda_i$
- SIFT (Scale Invariant Feature Transform)에서는 Harris Corner Detection을 사용함: Gradient로부터 계산된 Structure Tensor를 사용함.
Harris Corner Detection에 대한 참고자료:
https://dsaint31.me/mkdocs_site/DIP/ch02_02_02_harris_corner/
BME228
Harris and Stephen Corner Detection (1988) C.Harris and M.Stephens. A Combined Corner and Edge Detector. Proceedings of the 4th Alvey Vision Conference: pages 147-151, 1988. 특정 point가 corner, edge인지 여부를 식별할 수 있는 방법 : SIFT Fe
dsaint31.me
Stationary Point 의 종류 판정.
Optimization에서
- gradient를 통해 stationary point (solution의 필요조건을 만족시켜 solution일 가능성이 있는 후보들)들을 구한 다음,
- Hessian matrix를 통해 진짜 solution인지를 판별하는 게 일반적임.
이를 가르켜 Hessian 판정이라고도 부름.
어떤 함수의 critical point (or stationary point)에서 계산한 Hessian 행렬의
- 모든 고유값(eigenvalue)이 양수(positive)이면 해당 지점에서 함수는 Minimum(극소),
- 모든 고유값이 음수이면 Maximum(극대),
- 음의 고유값과 양의 고유값을 모두 가지면 saddle point인 것으로 판단
- Critical point : 1st order derivative가 0인 점. stationary point(정류점)라고도 불림.
- saddle point 의 경우, eigen value들이 음과 양을 모두 가지므로, 이들을 모두 곱한 determinant $\text{det} H (\textbf{x})=|H|$는 음이 된다: $|H|<0$.
Stationary Point란?
2023.07.10 - [.../Math] - [Math] Stationary point (or Critical point)
[Math] Stationary point (or Critical point)
Stationary point (or Critical point, 정류점)(Convex) Opimization에서 찾고자하는 solution은 objective function에 대한 local minimum이다.이를 곧바로 찾기는 쉽지 않기 때문에, solution이 될 수 있는 후보들을 먼저 gradie
dsaint31.tistory.com
Image Processing: Frangi filter
영상처리에서 Hessian은 edge, corner 검출등에 사용가능함.
- x축, y축에 대한 각 Hessian에서의 eigenvalue가 모두 클 경우 object의 corner에 해당.
- x축, y축에 대한 각 Hessian에서의 eigenvalue가 모두 작을 경우 object의 내부로 각 픽셀들이 비슷한 값을 가지고 있음.
- x축, y축에 대한 각 Hessian에서의 eigenvalue의 차이가 심할 경우 x축에 평행한 edge이거나 y축에 평행한 edge성분에 해당함.
Frangi filter는 Hessian의 eigenvalue 정보를 활용하여 혈관과 같은 선형 구조를 감지함:(ratio of eigenvalue를 이용)
관련 문헌:
- Alejandro F. Frangi, Wiro J. Niessen, Koen L. Vinc and Max A. Viergever (1998), "Multiscale Vessel Enhancement Filtering", Medical Image Computing and Computer-Assisted Interventation — MICCAI’98 Lecture Notes in Computer Science 1496/1998: 130.
![](https://blog.kakaocdn.net/dn/FLvBx/btrD1tbfH0Y/Y0HOatGIjJUsjMODp5p1Mk/img.png)
- Y. Sato, S. Nakajima, N. Shiraga, H. Atsumi, S.Yoshida, T.Koller, G. .Gerig, and R. Kikinis, “3D multi-scale line filter for segmentation and visualization of curvilinear
structures in medical images”, IEEE Medical Images Analysis, vol.2, pp.143-168, Jun. 1998. - M. Schirijver, C. H. Slump, “Automatic segmentation of the coronary artery tree in angiography projection”, Proc. of ProRISC 2002, pp.449-464
python에서 Frangi filter는 scikit image에서 제공하고 있으며 사용법은 다음과 같음.
from skimage.filters import frangi, hessian
import numpy as np
import cv2
import matplotlib.pyplot as plt
image = cv2.imread('./frangi_filter_src.png', cv2.IMREAD_GRAYSCALE)
fig, ax = plt.subplots(nrows=1, ncols=3, figsize = (20, 10))
ax[0].imshow(image, cmap=plt.cm.gray)
ax[0].set_title('Original image')
kwargs = {'sigmas': [1], 'mode': 'reflect'}
frangi_img = frangi(image,**kwargs)
ax[1].imshow(frangi_img, cmap=plt.cm.gray,
vmin=0, vmax=np.max(frangi_img)/10,
)
ax[1].set_title('Frangi filter result')
hessia_img = hessian(image,**kwargs)
ax[2].imshow(hessia_img, cmap=plt.cm.gray,
vmin=0, vmax=np.max(hessia_img),
)
ax[2].set_title('Hybrid Hessian filter result')
for a in ax:
a.axis('off')
plt.show()
result
![](https://blog.kakaocdn.net/dn/bn0mYm/btrDYd8qK3c/bG3k0buVfqckuz86g8KK8K/img.png)
References
2022.05.08 - [.../Math] - [Math] Matrix Calculus : Numerator Layout
[Math] Matrix Calculus : Numerator Layout
원본 : [Matrix Calculus](https://souryadey.github.io/teaching/material/Matrix_Calculus.pdf) 가급적 원본을 꼭 보길 권함. 1. Notation Scalar는 lower case letter로 표기. Vector는 lower case bold letter..
dsaint31.tistory.com
Ridge operators - skimage v0.19.2 docs
Ridge operators — skimage v0.19.2 docs
Ridge operators Ridge filters can be used to detect ridge-like structures, such as neurites , tubes , vessels , wrinkles or rivers. Different ridge filters may be suited for detecting different structures, e.g., depending on contrast or noise level. The pr
scikit-image.org
https://colab.research.google.com/drive/1aKfbvJ107RW7rsPVJf-lU7EULYvDqM02?usp=sharing
Hessian_Frangi_Filter.ipynb
Colaboratory notebook
colab.research.google.com
https://darkpgmr.tistory.com/132
Gradient, Jacobian 행렬, Hessian 행렬, Laplacian
Gradient(그레디언트), Jacobian(야코비언) 행렬, Hessian(헤시안) 행렬, Laplacian(라플라시안) ... 문득 정리의 필요성을 느껴서 적어봅니다. 이들을 함께 보는 이유는? 그냥 왠지 이들은 세트로 함께 봐야
darkpgmr.tistory.com
'Programming > DIP' 카테고리의 다른 글
[DIP] Color Space or Color Model (0) | 2022.09.21 |
---|---|
[OpenCV] cv2.cvtColor (0) | 2022.07.14 |
PIL과 opencv에서의 image 변환. (1) | 2021.11.22 |
Conda backup for DIP 2021 (0) | 2021.09.18 |
NumPy : sum, mean, std, and so on (0) | 2021.09.17 |