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:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,160 @@
---
id: wiki-2026-0508-straightening
title: Straightening
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Image Straightening, Perspective Correction, Deskew]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [computer-vision, image-processing, perspective-correction, opencv]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: python
framework: opencv
---
# Straightening
## 매 한 줄
> **"매 tilted image 의 axis-aligned 로 복원"**. Document scanning, satellite imagery, photo correction 의 fundamental preprocessing. Classical (Hough line + rotation, perspective transform) + modern deep learning (DeepDeskew, DocAligner) 의 combo.
## 매 핵심
### 매 두 가지 problem
- **Skew correction (rotation)**: 매 in-plane rotation 의 보정. Hough line 의 dominant angle detection.
- **Perspective correction (homography)**: 매 4-point 의 quadrilateral → rectangle. 매 non-frontal photo 의 document.
### 매 classical pipeline
1. Edge detection (Canny).
2. Line detection (Hough transform) 또는 corner detection.
3. Dominant angle estimation 또는 4-point selection.
4. Rotation matrix / homography 계산.
5. Warp (affine / perspective).
### 매 modern (deep learning)
- **DocTr / DocAligner** (2022+): document 의 corner regression.
- **CNN-based skew angle predictor**: 매 single forward pass.
- **LayoutLMv3-based**: 매 document understanding 의 part.
### 매 응용
1. Document scanning apps (CamScanner, Adobe Scan).
2. OCR preprocessing — 매 accuracy boost.
3. Satellite imagery alignment.
4. Receipt / business card capture.
## 💻 패턴
### Skew detection via Hough
```python
import cv2
import numpy as np
def detect_skew(img):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 50, 150)
lines = cv2.HoughLines(edges, 1, np.pi / 180, 200)
angles = [(theta * 180 / np.pi) - 90 for rho, theta in lines[:, 0]]
return np.median([a for a in angles if -45 < a < 45])
```
### Rotation correction
```python
def rotate_image(img, angle):
h, w = img.shape[:2]
center = (w // 2, h // 2)
M = cv2.getRotationMatrix2D(center, angle, 1.0)
return cv2.warpAffine(img, M, (w, h), flags=cv2.INTER_CUBIC,
borderMode=cv2.BORDER_REPLICATE)
```
### Perspective correction (4-point)
```python
def four_point_transform(img, pts):
rect = order_points(pts)
(tl, tr, br, bl) = rect
width = max(np.linalg.norm(br - bl), np.linalg.norm(tr - tl))
height = max(np.linalg.norm(tr - br), np.linalg.norm(tl - bl))
dst = np.array([[0, 0], [width-1, 0], [width-1, height-1], [0, height-1]],
dtype="float32")
M = cv2.getPerspectiveTransform(rect, dst)
return cv2.warpPerspective(img, M, (int(width), int(height)))
def order_points(pts):
rect = np.zeros((4, 2), dtype="float32")
s = pts.sum(axis=1); diff = np.diff(pts, axis=1)
rect[0] = pts[np.argmin(s)]; rect[2] = pts[np.argmax(s)]
rect[1] = pts[np.argmin(diff)]; rect[3] = pts[np.argmax(diff)]
return rect
```
### Document corner detection (modern)
```python
# OpenCV contour-based (heuristic)
def find_document_corners(img):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edges = cv2.Canny(blurred, 75, 200)
cnts, _ = cv2.findContours(edges, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
cnts = sorted(cnts, key=cv2.contourArea, reverse=True)[:5]
for c in cnts:
approx = cv2.approxPolyDP(c, 0.02 * cv2.arcLength(c, True), True)
if len(approx) == 4:
return approx.reshape(4, 2)
return None
```
### Deep learning approach (DocAligner-style)
```python
import torch
from torchvision import transforms
class CornerRegressor(torch.nn.Module):
def __init__(self, backbone):
super().__init__()
self.backbone = backbone # ResNet34
self.head = torch.nn.Linear(512, 8) # 4 corners x (x, y)
def forward(self, x):
feat = self.backbone(x)
corners = self.head(feat).view(-1, 4, 2)
return torch.sigmoid(corners) # normalized [0, 1]
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 simple skew (rotation only) | Hough line + rotate |
| 매 document photo | 4-point perspective |
| 매 noisy / cluttered scene | DL corner regressor |
| 매 mobile real-time | Lightweight CNN (MobileNet) |
| 매 batch / cloud | LayoutLMv3 + classical refinement |
**기본값**: 매 document → contour-based 4-point. 매 OCR pipeline → DocAligner.
## 🔗 Graph
- 부모: [[Computer Vision|Computer-Vision]]
- 응용: [[OCR]]
## 🤖 LLM 활용
**언제**: OCR 의 preprocessing pipeline, document understanding 의 normalization, vision-language model 의 input quality 개선.
**언제 X**: 매 ill-defined edges (handwriting on textured background), 매 already aligned image (overhead).
## ❌ 안티패턴
- **Single Hough line**: 매 outlier 의 dominate. median angle 사용.
- **Aggressive crop**: rotation 후 black border 의 crop 시 content loss.
- **Over-correction**: 매 small skew (< 0.5°) 무시 — overhead > benefit.
## 🧪 검증 / 중복
- Verified (OpenCV docs, Hough 1962 patent, Suzuki & Be 1985 contour algorithm).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Hough + perspective + DL corner coverage |