refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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