Metadata-Version: 2.4
Name: srrt
Version: 0.1.1
Summary: Recolor a person image toward a reference skin colour inside a mask.
License-Expression: MIT
Project-URL: Homepage, https://pypi.org/project/srrt/
Keywords: skin,color-transfer,recolor,image
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Multimedia :: Graphics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: opencv-python-headless>=4.8
Provides-Extra: idt
Requires-Dist: scipy>=1.10; extra == "idt"
Dynamic: license-file

# srrt

Recolor a person toward a reference skin colour. You pass the colour, the photo, and a mask of the person. The result is a BGR image with that region moved toward the reference and a soft edge.

```python
from srrt import transfer

result = transfer("#C68642", "person.jpg", "person_mask.png")
```

`result` is a `uint8` BGR array, the same size as the photo.

## Install

```bash
pip install srrt
```

Histogram-rotation mode (`idt`) needs SciPy:

```bash
pip install "srrt[idt]"
```

## Inputs

| Argument | What it is |
| --- | --- |
| `reference_color` | `#RRGGBB`, `#RGB`, `"R,G,B"`, an RGB tuple, or a close-up skin photo (path or BGR array) |
| `human_image` | Person photo (path or BGR array) |
| `human_mask` | Mask of the same height and width. Non-zero pixels are recolored |

Colours are RGB. Image arrays follow OpenCV and are BGR.

A binary mask is feathered over a few pixels. A soft mask (values other than only 0 and 255) is used as the blend itself. Bright, low-chroma pixels inside the mask, such as teeth and eye whites, stay on the original colour.

```python
import cv2
from srrt import transfer

image = cv2.imread("person.jpg")
mask = cv2.imread("person_mask.png", cv2.IMREAD_GRAYSCALE)
result = transfer((198, 134, 66), image, mask, strength=0.8)
cv2.imwrite("out.jpg", result)
```

A reference photo is sampled the same way as a flat colour:

```python
result = transfer("skin_reference.jpg", image, mask)
```

## Options

| Argument | Default | Meaning |
| --- | --- | --- |
| `strength` | `0.8` | `0` leaves the photo unchanged, `1` applies the full transfer |
| `feather` | `3` | Edge width in pixels for a binary mask |
| `luma_shift` | `1.0` | `0` keeps original lightness, `1` matches the reference lightness |
| `erode` | `4` | Border pixels left out of the source colour estimate |
| `protect_whites` | `True` | Keep teeth and eye whites |
| `seed` | `0` | Sampler seed |

## Command line

```bash
srrt --reference "#C68642" --image person.jpg --mask person_mask.png --output out.jpg
srrt --reference skin_reference.jpg --image person.jpg --mask person_mask.png --output out.jpg --strength 1
```

## Author
vijeshkpaei@gmail.com

