Skip to main content

Computer vision utilities for dataset visualization

Project description

haechan

Computer vision utilities for dataset visualization.

Installation

pip install haechan

Optional external tools for export optimization:

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

Usage

blend

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

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를 추가해 어떤 이미지에서도 가독성을 보장합니다.

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

from haechan import save_img

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

save_gif

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가 필요합니다.

from haechan import save_video

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

palette / get_colors

from haechan import palette, get_colors

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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

haechan-0.1.7.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

haechan-0.1.7-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file haechan-0.1.7.tar.gz.

File metadata

  • Download URL: haechan-0.1.7.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for haechan-0.1.7.tar.gz
Algorithm Hash digest
SHA256 c600bf208181f9a59584271115a21c044480fbde1b51fac8a551ee618fdf3a59
MD5 2c9d039165b16902e1f0342c4a3bbc9c
BLAKE2b-256 109a32818c27fa6ca68502823a388357b94a54165f9795da575f53019ecfac33

See more details on using hashes here.

File details

Details for the file haechan-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: haechan-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for haechan-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6d14e44bb81cc5e9f72ca31c02ba9a27cbc9f5efc29804e87d41897423076187
MD5 c57544feec9f29280b0f4e7258293296
BLAKE2b-256 12d0cd1ca832458599deb4848a7f30a88d50e460e703926e062f9312860091c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page