docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
---
|
||||
id: wiki-2026-0508-shape-feature-extraction
|
||||
title: Shape Feature Extraction
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Shape Descriptors, HOG, SIFT, Contour Features]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [computer-vision, feature-extraction, image-processing]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: OpenCV / scikit-image / PyTorch
|
||||
---
|
||||
|
||||
# Shape Feature Extraction
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 image / object 에서 numerical descriptor 뽑기 — boundary, region, gradient"**. 매 classical (HOG, SIFT, Hu moments, Fourier descriptors) 부터 매 deep features (CNN backbone, DINOv2/v3, SAM2 mask embedding) 까지의 spectrum. 매 2026 default: deep features for recognition, classical for low-data / explainable / edge.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 분류
|
||||
- **Boundary-based**: contour chain code, Fourier descriptors, polygon approx.
|
||||
- **Region-based**: area, perimeter, eccentricity, Hu moments (rotation/scale invariant).
|
||||
- **Gradient-based**: HOG (Dalal 2005), SIFT (Lowe 2004), SURF, ORB.
|
||||
- **Texture+shape**: LBP, GLCM.
|
||||
- **Deep**: CNN penultimate layer, ViT [CLS] token, DINOv3 patch features.
|
||||
|
||||
### 매 Invariance 요구
|
||||
- Translation: 매 거의 모든 method.
|
||||
- Rotation: Hu moments, SIFT, RIFT.
|
||||
- Scale: SIFT, multi-scale CNN.
|
||||
- Illumination: HOG (gradient), normalized embeddings.
|
||||
- Affine: ASIFT.
|
||||
|
||||
### 매 응용
|
||||
1. Object recognition (legacy + edge).
|
||||
2. Image retrieval / re-id (deep embeddings).
|
||||
3. OCR pre-processing (contour).
|
||||
4. Medical imaging (lesion shape descriptors).
|
||||
5. Industrial defect inspection.
|
||||
6. Robot grasp planning (object silhouette).
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Contour features (OpenCV)
|
||||
```python
|
||||
import cv2, numpy as np
|
||||
gray = cv2.imread("obj.png", 0)
|
||||
_, bw = cv2.threshold(gray, 0, 255, cv2.THRESH_OTSU)
|
||||
contours, _ = cv2.findContours(bw, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
c = max(contours, key=cv2.contourArea)
|
||||
area = cv2.contourArea(c)
|
||||
peri = cv2.arcLength(c, True)
|
||||
circ = 4 * np.pi * area / (peri ** 2)
|
||||
hu = cv2.HuMoments(cv2.moments(c)).flatten()
|
||||
```
|
||||
|
||||
### HOG
|
||||
```python
|
||||
from skimage.feature import hog
|
||||
feat, vis = hog(gray, orientations=9, pixels_per_cell=(8,8),
|
||||
cells_per_block=(2,2), visualize=True)
|
||||
```
|
||||
|
||||
### SIFT (OpenCV)
|
||||
```python
|
||||
sift = cv2.SIFT_create()
|
||||
kp, desc = sift.detectAndCompute(gray, None) # desc: (N, 128)
|
||||
```
|
||||
|
||||
### Fourier descriptors
|
||||
```python
|
||||
def fourier_descriptors(contour, k=20):
|
||||
pts = contour[:, 0, 0] + 1j * contour[:, 0, 1]
|
||||
fd = np.fft.fft(pts)
|
||||
fd[0] = 0 # translation invariant
|
||||
fd /= np.abs(fd[1]) # scale invariant
|
||||
return np.abs(fd[1:k+1]) # rotation invariant (magnitude)
|
||||
```
|
||||
|
||||
### Deep feature (DINOv3)
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoModel, AutoImageProcessor
|
||||
proc = AutoImageProcessor.from_pretrained("facebook/dinov3-base")
|
||||
model = AutoModel.from_pretrained("facebook/dinov3-base").eval().cuda()
|
||||
inp = proc(img, return_tensors="pt").to("cuda")
|
||||
with torch.no_grad():
|
||||
feats = model(**inp).last_hidden_state # (1, N+1, D)
|
||||
cls_emb = feats[:, 0] # global shape/appearance
|
||||
```
|
||||
|
||||
### SAM2 mask + descriptor pipeline
|
||||
```python
|
||||
from sam2.build_sam import build_sam2
|
||||
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
||||
sam = build_sam2("sam2_hiera_l.yaml", "sam2_l.pt")
|
||||
pred = SAM2ImagePredictor(sam)
|
||||
pred.set_image(img)
|
||||
masks, _, _ = pred.predict(point_coords=pts, point_labels=lbl)
|
||||
# 매 mask 내부 영역만 dino feature 뽑기 → object-centric descriptor
|
||||
```
|
||||
|
||||
### Image retrieval pipeline
|
||||
```python
|
||||
emb = []
|
||||
for p in paths:
|
||||
e = dino_embed(load(p))
|
||||
emb.append(e / e.norm())
|
||||
emb = torch.stack(emb)
|
||||
# query
|
||||
q = dino_embed(load(query))
|
||||
q /= q.norm()
|
||||
sims = (emb @ q.T).flatten()
|
||||
topk = sims.topk(10).indices
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Modern recognition / retrieval | DINOv3 / CLIP embedding |
|
||||
| Explainable / regulatory | Hu moments, contour |
|
||||
| Real-time embedded | ORB or tiny CNN |
|
||||
| Robust to occlusion | local features (SIFT/SuperPoint) |
|
||||
| Mask 필요 + descriptor | SAM2 + DINO |
|
||||
|
||||
**기본값**: DINOv3 embedding for general purpose.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Computer Vision|Computer-Vision]] · [[Feature-Extraction]]
|
||||
- 변형: [[HOG]] · [[SIFT]]
|
||||
- 응용: [[OCR]]
|
||||
- Adjacent: [[Image-Segmentation]] · [[CLIP]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: dataset 작거나 explainability 요구 → classical. Otherwise deep.
|
||||
**언제 X**: 매 generic image classification — end-to-end deep model 가 매 simpler.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **HOG + SVM in 2026**: deep baseline 보다 명확히 약함 unless tiny data.
|
||||
- **Hand-crafted features then deep classifier**: 매 mismatch — pick one paradigm.
|
||||
- **No normalization**: scale/illumination drift → 매 retrieval 실패.
|
||||
- **SIFT 특허 우려**: 2020+ 매 expired, 그래도 license 확인.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Lowe 2004 SIFT, Dalal 2005 HOG, OpenCV docs, DINOv3 paper).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — classical + DINOv3/SAM2 2026 |
|
||||
Reference in New Issue
Block a user