Metadata-Version: 2.4
Name: haechan
Version: 0.1.7
Summary: Computer vision utilities for dataset visualization
Project-URL: Homepage, https://github.com/haechan/haechan
Author: haechan
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.8
Requires-Dist: numpy
Requires-Dist: pillow
Description-Content-Type: text/markdown

# haechan

Computer vision utilities for dataset visualization.

## Installation

```bash
pip install haechan
```

Optional external tools for export optimization:

```bash
brew install gifsicle  # GIF 후처리 압축
brew install ffmpeg    # MP4 저장
```

## Usage

### blend

세그멘테이션 마스크를 이미지에 오버레이합니다.

```python
import numpy as np
from haechan import blend, palette

img  = np.array(Image.open("image.jpg"))   # H x W x 3, uint8
mask = np.array(Image.open("mask.png"))    # H x W, int (class index)
fg   = mask > 0                            # 전경 boolean mask

# 기본 사용
blended = blend(img, mask, fg)

# 마스크 크기가 다를 때 — aspect ratio 유지하며 max 320px로 리사이즈
blended = blend(img, mask, fg, resize=True)
```

### label

마스크 중심에 클래스 이름 태그를 그립니다. 배경색 밝기에 따라 텍스트 색을 자동 선택하고 stroke를 추가해 어떤 이미지에서도 가독성을 보장합니다.

```python
from PIL import Image, ImageDraw
from haechan import label

pil_img = Image.fromarray(blended)
draw    = ImageDraw.Draw(pil_img)

label(draw, mask == 1, text="person", color=(255, 0, 0))
```

> `mask`와 이미지 크기가 달라도 자동으로 좌표를 스케일링합니다.

### save_img

```python
from haechan import save_img

save_img(blended, "output.jpg")          # numpy array 또는 PIL Image
save_img(pil_img, "output.png")
```

### save_gif

```python
from haechan import save_gif

frames = [Image.open(f"frame{i}.png") for i in range(10)]

save_gif(frames, "output.gif", duration=200)

# gifsicle로 후처리 압축 (--lossy=80 --optimize=3)
save_gif(frames, "output.gif", duration=200, optimize=True)
```

### save_video

MP4로 저장합니다. ffmpeg가 필요합니다.

```python
from haechan import save_video

save_video(frames, "output.mp4", fps=10)
```

### palette / get_colors

```python
from haechan import palette, get_colors

colors = palette()                  # 254색 고정 팔레트, list of (R, G, B)
colors = get_colors(num_classes=80) # 원하는 클래스 수만큼
```

## License

MIT
