이 문서는 Numeartor Layout Convention 을 사용함.
Hessian : Summary
2nd order derivative of multivariate functoin.
- 여기서 multivariate function은 입력은 vector, 출력은 scalar
Hessian matrix는 다음과 같음.
$$\begin{aligned}H[f](\textbf{x})=H(\textbf{x})&=\left(J\left[\nabla f(\textbf{x})\right]\right)^T\\ &= \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}$$
Hessian matrix의 $(i,j)$ 요소의 general form은 다음과 같음.
$$
H_{ij}=\dfrac{\partial^2 f}{\partial x_i \partial x_j}
$$
Hessian matrix 는 $f$가 이차미분가능하고 이차미분 결과가 연속인 경우 구해지며 항상 symmetric matrix 임.
- This is in general only true, if the second partial derivatives are continuous. This is called Schwarz's theorem.
- Symmetric matrix 는 항시 eigen decomposition이 가능함.
- $n \times n$ Hessian matrix는 항시 orthonormal eigen vector를 $n$개 가짐.
Hessian 행렬의
1. 고유벡터(eigenvector)는 함수의 곡률이 큰 방향벡터임.
2. 고유값(eigenvalue)은 해당 고유벡터(eigenvector) 방향으로의 함수의 곡률(curvature, 이차미분값)임.
- 해당 값의 크기(absolute value)은 convex 등에서 그래프의 폭을 결정함.
- 클수록 폭이 좁음. (= curvature, 곡률이 큼)
Stationary Point 의 종류 판정.
Optimization에서
- gradient를 통해 stationary point (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$.
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성분에 해당함.
관련 문헌:
- 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] 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 |